\documentclass[12pt]{article}
\usepackage{times}
\usepackage{graphicx}
\usepackage{sidecap}
\usepackage{wrapfig}
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\baselinestretch}{1.2}
\newenvironment{mylisting}
{\begin{list}{}{\setlength{\leftmargin}{1em}}\item\scriptsize\bfseries}
{\end{list}}
%%% This file is Open Content

\begin{document}
	\textbf{{\Huge Kobold's Quest 1}}
{\center{Dec 29, 2011, 
	Johan Ceuppens, Theo D'Hondt - Vrije Universiteit Brussel}}
\\
{\large{\textbf{\center Abstract}}}
\\
\\
\section{\large Introduction}

FIXME Python game code

\begin{mylisting}
\begin{verbatim}

	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010
# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemangel import *

class Angel(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemangel())
        self.addimage('angel1.bmp',255,255,255)
        self.addimage('angel2.bmp',255,255,255)
        self.addimage('angel3.bmp',255,255,255)
        self.addimage('angel4.bmp',255,255,255)
        self.addimage('angel3.bmp',255,255,255)
        self.addimage('angel2.bmp',255,255,255)
        self.counter = 0
	self.decreasehp = 0
	self.usedspellbookdracolich = 0

####### TEXT / FONT interface
    def getname(self,text):
        return text.getangelname()

#    def gettalk(self):
#        talksystem.gettalk(self)

####### other methods
    def draw(self,screen):

	if self.usedspellbookdracolich > 0:
      	    font = pygame.font.SysFont("Vera", 32)
            screen.scr.blit(font.render("The spellbook disappears in the angel's hands!", 16, (255,255,255)), (20,300))
	    screen.scr.blit(self.images[3], (self.x, self.y))
	    return

        self.counter += 1

        if self.counter >= 60:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x, self.y))
        elif self.counter < 60:
            screen.scr.blit(self.images[5], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the angel."
            return 1
        else:
            return None

    def usedracolichspellbook(self,game):
        string = "You have destroyed the dracolich's spellbook"
        string += "\n"
        print "BAZ"

	s = ""

        f = open("./workfile",'r')
        for line in f:
            s += line
                
        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

	self.usedspellbookdracolich = 1



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemassassin import *
from entityfactory import *
from food import *

class Assassin(Enemytalking):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemassassin())
        self.addimage('rogueassassin1.bmp',0,0,0)
        self.addimage('rogueassassin1.bmp',0,0,0)
        self.addimage('rogueassassin1.bmp',0,0,0)
        self.addimage('rogueassassin1.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
        self.addimage('rogueassassin3.bmp',0,0,0)
        self.addimage('rogueassassin3.bmp',0,0,0)
        self.addimage('rogueassassin3.bmp',0,0,0)
        self.addimage('rogueassassin3.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
        self.addimage('rogueassassin2.bmp',0,0,0)
	self.images2 = []
        self.addimage2('rogueassassinup1.bmp',0,0,0)
        self.addimage2('rogueassassinup1.bmp',0,0,0)
        self.addimage2('rogueassassinup1.bmp',0,0,0)
        self.addimage2('rogueassassinup1.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)
        self.addimage2('rogueassassinup3.bmp',0,0,0)
        self.addimage2('rogueassassinup3.bmp',0,0,0)
        self.addimage2('rogueassassinup3.bmp',0,0,0)
        self.addimage2('rogueassassinup3.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)
        self.addimage2('rogueassassinup2.bmp',0,0,0)

        self.counter = 0

	self.direction = "down"
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getassassinname()

#### NEW FUNCTION
    def addimage2(self,filename,r,g,b):# rgb transparency values
### NOTE same number of images already        self.maximages2 += 1

        image2 = pygame.image.load(filename).convert()
        image2.set_colorkey((r,g,b))
        self.images2.append(image2)

    def collisionboxesnew(self,room):
        o = self.collisionlist(room.boxes)
        if o:
            #self.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):
	if self.entangled:
		return
	if self.collisionboxesnew(room):### JUMP
		if self.direction == "up":
			self.y += 3 
			self.direction = "down"
		elif self.direction == "down":
			self.y -= 3
			self.direction = "up"

	if self.direction == "up":
		self.y -= 1
	elif self.direction == "down":
		self.y += 1

####### other methods
    def drawonmap(self, screen, maproom):
        self.imagescounter += 1
        if self.imagescounter == self.maximages:
            self.imagescounter = 0    
	if self.direction == "down": 
        	screen.scr.blit(self.images[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))
	elif self.direction == "up": 
        	screen.scr.blit(self.images2[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))

    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The assassin drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the knight."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def bounceback(self):
        if self.direction == "up":#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == "down":#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == "left":#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == "right":#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	#r = randint(1,4)
	#self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemassassinqueen import *
from entityfactory import *
from food import *

class Assassinqueen(Enemytalking):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemassassinqueen())
        self.addimage('assassinprincess1.bmp',0,0,0)
        self.addimage('assassinprincess1.bmp',0,0,0)
        self.addimage('assassinprincess1.bmp',0,0,0)
        self.addimage('assassinprincess1.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
        self.addimage('assassinprincess3.bmp',0,0,0)
        self.addimage('assassinprincess3.bmp',0,0,0)
        self.addimage('assassinprincess3.bmp',0,0,0)
        self.addimage('assassinprincess3.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
        self.addimage('assassinprincess2.bmp',0,0,0)
	self.images2 = []
        self.addimage2('assassinprincessup1.bmp',0,0,0)
        self.addimage2('assassinprincessup1.bmp',0,0,0)
        self.addimage2('assassinprincessup1.bmp',0,0,0)
        self.addimage2('assassinprincessup1.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)
        self.addimage2('assassinprincessup3.bmp',0,0,0)
        self.addimage2('assassinprincessup3.bmp',0,0,0)
        self.addimage2('assassinprincessup3.bmp',0,0,0)
        self.addimage2('assassinprincessup3.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)
        self.addimage2('assassinprincessup2.bmp',0,0,0)

        self.counter = 0

	self.direction = "down"
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getassassinqueenname()

#### NEW FUNCTION
    def addimage2(self,filename,r,g,b):# rgb transparency values
### NOTE same number of images already        self.maximages2 += 1

        image2 = pygame.image.load(filename).convert()
        image2.set_colorkey((r,g,b))
        self.images2.append(image2)

    def collisionboxesnew(self,room):
        o = self.collisionlist(room.boxes)
        if o:
            #self.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):
	if self.entangled:
		return
	if self.collisionboxesnew(room):### JUMP
		if self.direction == "up":
			self.y += 3 
			self.direction = "down"
		elif self.direction == "down":
			self.y -= 3
			self.direction = "up"

	if self.direction == "up":
		self.y -= 1
	elif self.direction == "down":
		self.y += 1

####### other methods
    def drawonmap(self, screen, maproom):
        self.imagescounter += 1
        if self.imagescounter == self.maximages:
            self.imagescounter = 0    
	if self.direction == "down": 
        	screen.scr.blit(self.images[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))
	elif self.direction == "up": 
        	screen.scr.blit(self.images2[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))

    def draw(self,screen):
        self.imagescounter += 1
        if self.imagescounter == self.maximages:
            self.imagescounter = 0    
	if self.direction == "down": 
        	screen.scr.blit(self.images[self.imagescounter], (self.x, self.y))
	elif self.direction == "up": 
        	screen.scr.blit(self.images2[self.imagescounter], (self.x, self.y))



#        self.counter += 1

#        if self.counter >= 40:
#            self.counter = 0

#        if self.counter < 10:
#            screen.scr.blit(self.images[0], (self.x, self.y))
#        elif self.counter < 20:
#            screen.scr.blit(self.images[1], (self.x, self.y))
#        elif self.counter < 30:
#            screen.scr.blit(self.images[2], (self.x, self.y))
#        elif self.counter < 40:
#            screen.scr.blit(self.images[3], (self.x, self.y))
#	if self.entangled:
#        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
#        	rootsimage.set_colorkey((0,0,0))
#        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the knight."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def bounceback(self):
        if self.direction == "up":#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == "down":#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == "left":#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == "right":#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	#r = randint(1,4)
	#self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Batcrazy(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h)
        self.addimage('batcrazy1.bmp',255,255,255)
        self.addimage('batcrazy2.bmp',255,255,255)
        self.addimage('batcrazy3.bmp',255,255,255)
        self.addimage('batcrazy4.bmp',255,255,255)
        self.counter = 0
	self.direction = 1

    def getname(self,text):
        return text.getbatname()


    def draw(self,screen):
        self.counter += 1

        if self.counter >= 60:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 60:
            screen.scr.blit(self.images[1], (self.x, self.y))
    


    def update(self,room):#FIXME all level arg must be room

        r = randint(0,3)
	if r == 0:
	    self.direction = randint(1,4)
        if self.direction == 0:
            self.x += 1
        if self.direction == 1:
            self.x -= 1
        if self.direction == 2:
            self.y += 1
        if self.direction == 3:
            self.y -= 1
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Bat(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h)
        self.addimage('bat1.bmp',0,0,0)
        self.addimage('bat2.bmp',0,0,0)
        self.addimage('bat3.bmp',0,0,0)
        self.counter = 0

    def getname(self,text):
        return text.getbatname()


    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystembirdsparrow import *
from entityfactory import *
from food import *

class Birdsparrow(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystembirdsparrow())
        self.addimage('birdsparrow1.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getbirdsparrowname()

#    def gettalk(self):
#        talksystem.gettalk(self)
    def update(self,room):
	1

####### other methods
    def draw(self,screen):
#        self.counter += 1

        screen.scr.blit(self.images[0], (self.x, self.y))
#        if self.counter >= 40:
#            self.counter = 0

#        if self.counter < 10:
#            screen.scr.blit(self.images[0], (self.x, self.y))
#        elif self.counter < 20:
#            screen.scr.blit(self.images[1], (self.x, self.y))
#        elif self.counter < 30:
#            screen.scr.blit(self.images[2], (self.x, self.y))
#        elif self.counter < 40:
#            screen.scr.blit(self.images[1], (self.x, self.y))
        

    def leftbuttonpressed(self,game):#mouse,text,press0):
        if game.mouse.press(0) == 1:
            self.talkcounter += 1
            if self.talkcounter == 1:
                self.currenttext = self.talksystem.gettalk(game.text)#foo
            return self.currenttext
        else:
            self.talkcounter = 0
	    game.gamepoints.set("talkedtobirdsparrow")	
            return self.currenttext

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the birdsparrow."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemblimp import *
from entityfactory import *
from food import *

class Blimp(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemblimp())
        self.addimage('blimp1-300x300.bmp',0,0,0)
        self.addimage('blimp2-300x300.bmp',0,0,0)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getblimpname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 150:
            self.counter = 0

        if self.counter < 140:
            screen.scr.blit(self.images[0], (self.x, self.y))
	else:            
	    screen.scr.blit(self.images[1], (self.x, self.y))

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the blimp."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from sprite import *

from random import *

class Bomb(Sprite):
    def __init__(self,x,y,w,h):
        Sprite.__init__(self,x,y,w,h)
        self.addimage('bomb1.bmp',0,0,0)
        self.addimage('bomb2.bmp',0,0,0)

        self.addimage('bombexplosion1.bmp',0,0,0)
        self.addimage('bombexplosion2.bmp',0,0,0)
        self.addimage('bombexplosion3.bmp',0,0,0)
        self.addimage('bombexplosion4.bmp',0,0,0)
        self.addimage('bombexplosion5.bmp',0,0,0)
        self.addimage('bombexplosion6.bmp',0,0,0)
        self.addimage('bombexplosion7.bmp',0,0,0)
        self.addimage('bombexplosion8.bmp',0,0,0)

        self.counter = 0

    def drawonmap(self,screen,maproom):
        self.x += maproom.relativex
        self.y += maproom.relativey
        self.draw(screen)
        self.x -= maproom.relativex
        self.y -= maproom.relativey

    def draw(self,screen):

        print 'draw %d' % (self.counter)

        if self.counter >= 130:
            screen.scr.blit(self.images[9], (self.x-37, self.y-37))
        if self.counter >= 125:
            screen.scr.blit(self.images[8], (self.x-37, self.y-37))
        if self.counter >= 120:
            screen.scr.blit(self.images[7], (self.x-37, self.y-37))
        elif self.counter >= 115:
            screen.scr.blit(self.images[6], (self.x-37, self.y-37))
        elif self.counter >= 110:
            screen.scr.blit(self.images[5], (self.x-37, self.y-37))
        elif self.counter >= 105:
            screen.scr.blit(self.images[4], (self.x-37, self.y-37))
        elif self.counter >= 100:
            screen.scr.blit(self.images[3], (self.x-37, self.y-37))
        elif self.counter >= 90:
            screen.scr.blit(self.images[2], (self.x-37, self.y-37))
        elif self.counter >= 85:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter >= 80:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter >= 75:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter >= 70:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter >= 65:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter >= 60:
            screen.scr.blit(self.images[1], (self.x, self.y))
        else:
            screen.scr.blit(self.images[0], (self.x, self.y))
    

    def update(self,level):
        self.counter += 1
        
        if self.counter > 100:
            level.collisionandremoveenemieswithbomb(self)
            level.entities.remove(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemmyconid import *
from entityfactory import *
from food import *

class Bouncer(Enemytalking):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemmyconid())
        self.addimage('myconidblue1.bmp',255,255,255)
        self.addimage('myconidblue2.bmp',255,255,255)
        self.addimage('myconidblue3.bmp',255,255,255)
        self.counter = 0
	self.direction = 1 
	self.boxes = boxes
####### TEXT / FONT interface
    def getname(self,text):
        return text.getmyconidbluename()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The myconidblue drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the myconidblue."
            return 1
        else:
            return None

    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room
	o = None
	o = self.collisionboxes()

	if o:
	    r = randint(0,40)
	    if r < 2:
	        self.bounceback(None) 	
        if self.direction == 1:#north
	     self.y -= 1
        elif self.direction == 3:#south
 	     self.y += 1
        elif self.direction == 4:#west
             self.x -= 1
        elif self.direction == 2:#east
	     self.x += 1

    def bounceback(self,level):
        if self.direction == 1:#north
	    self.y += 2 
        elif self.direction == 3:#south
	    self.y -= 2
        elif self.direction == 4:#west
	    self.x -= 2
        elif self.direction == 2:#east
	    self.x += 2
	# set direction
	r = randint(1,4)
	self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Box:
    "Box"
    def __init__(self,x,y,w,h):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
    
    #FIXME copy-paste entity
    def addtolist(self,list):
        list.addobject(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class TriBox:
    "Triangular Box"
    def __init__(self,x1,y1,x2,y2):
        self.x1 = x1
        self.y1 = y1
        self.x2 = x2
        self.y2 = y2
    
    #FIXME copy-paste entity
    def addtolist(self,list):
        list.addobject(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Candle1(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('candle1.bmp',0,0,0)

        self.counter = 0

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    def getname(self,text):
        return text.getcandlename()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from enemytalking import *
from talksystemcandleflame2 import *

from random import *
import os

from utility import *

class Candleflame2(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemcandleflame2())
        self.counter = 0
        self.addimage('candleflame1.bmp',255,255,255)
        self.addimage('candleflame2.bmp',255,255,255)
        self.addimage('candleflame3.bmp',255,255,255)

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    def remove(self,list):
        list.remove(self)
	return None
    
 
    def getname(self,text):
        return text.getcandleflame1name()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from enemytalking import *
from talksystemcandleflame1 import *

from random import *
import os

from utility import *

class Candleflame1(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemcandleflame1())
        self.counter = 0
        self.addimage('candleflame1.bmp',255,255,255)
        self.addimage('candleflame2.bmp',255,255,255)
        self.addimage('candleflame3.bmp',255,255,255)

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    def remove(self,list):
        list.remove(self)
	return None
    
 
    def getname(self,text):
        return text.getcandleflame1name()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#from bouncer import *
from enemytalking import *
from talksystemchaosknight1 import *
from entityfactory import *
from food import *

class Chaosknight1(Enemytalking):#Bouncer):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemchaosknight1())
        self.addimage('chaosknight1.bmp',255,255,255)
        self.addimage('chaosknight1.bmp',255,255,255)
        self.addimage('chaosknight1.bmp',255,255,255)
        self.counter = 0

	self.direction = 1 
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getchaosknight1name()

#    def gettalk(self):
#        talksystem.gettalk(self)
#    def update(self,room):
#	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The chaosknight1 drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the chaosknight1."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room
	ri = randint(0,42)
	if ri == 14:
	    r = randint(1,4)
	    self.direction = r
	o = None
	o = self.collisionboxes()

	if o:
	    r = randint(0,40)
	    if r < 2:
	        self.bounceback(None) 	
        if self.direction == 1:#north
	     self.y -= 1
        elif self.direction == 3:#south
 	     self.y += 1
        elif self.direction == 4:#west
             self.x -= 1
        elif self.direction == 2:#east
	     self.x += 1

    def bounceback(self,level):
        if self.direction == 1:#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == 3:#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == 4:#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == 2:#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	r = randint(1,4)
	self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#from bouncer import *
from enemytalking import *
from talksystemchaosknight1 import *
from entityfactory import *
from food import *

class Chaosknight2(Enemytalking):#Bouncer):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemchaosknight1())
        self.addimage('chaosknight2.bmp',0,0,0)
        self.addimage('chaosknight2.bmp',0,0,0)
        self.addimage('chaosknight2.bmp',0,0,0)
        self.counter = 0

	self.direction = 1 
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getchaosknight1name()

#    def gettalk(self):
#        talksystem.gettalk(self)
#    def update(self,room):
#	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The chaosknight2 drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the chaosknight2."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room
	ri = randint(0,42)
	if ri == 14:
	    r = randint(1,4)
	    self.direction = r
	o = None
	o = self.collisionboxes()

	if o:
	    r = randint(0,40)
	    if r < 2:
	        self.bounceback(None) 	
        if self.direction == 1:#north
	     self.y -= 1
        elif self.direction == 3:#south
 	     self.y += 1
        elif self.direction == 4:#west
             self.x -= 1
        elif self.direction == 2:#east
	     self.x += 1

    def bounceback(self,level):
        if self.direction == 1:#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == 3:#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == 4:#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == 2:#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	r = randint(1,4)
	self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemcherubstatue1 import *

class Cherubstatue1(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemcherubstatue1())
        self.addimage('cherubstatue1.bmp',255,255,255)

####### TEXT / FONT interface
    def getname(self,text):
        return text.getcherubstatuename()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
      screen.scr.blit(self.images[0], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def update(self,room):
	1

    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the myconid."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *
### This chest contains a healing potion
class Chest1(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('chest1.bmp',0,0,0)
        self.addimage('chest2.bmp',0,0,0)
        self.addimage('chest3.bmp',0,0,0)
        self.addimage('chest4.bmp',0,0,0)
        self.addimage('chest5.bmp',0,0,0)
        self.addimage('chest6.bmp',0,0,0)
        self.addimage('chest7.bmp',0,0,0)
        self.addimage('chest8.bmp',0,0,0)
	self.addimage('chest1contents.bmp',0,0,0)

        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber
	self.counter = 0
	self.flag = 0

    def remove(self,list):
        string = "You have a chest "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""
	if self.flag == 1:
		return None
	self.flag = 1
        ###if Utilities().readandfindstring(string):
        ###    list.remove(self)
       	###    return None
 
        f = open("./workfile",'r')
        for line in f:
            s += line
        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

	return 1 

    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):

        string = "You have a chest "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            ### print "+++ Chest1 registered"
	    ### NOTE : do not remove, only after drinking remove
            ###if list:
            ###    list.remove(self)
            return None ### None 

	return 1 ### None?  

    def readkeys2(self, list):
        string = "You drank the healing potion - chest 1"
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ Chest1 Contents registered"
            ###if list:
            ###    list.remove(self)
            return None 

	return 1

    def update(self,room):
	1

    def deathupdate(self):
	1		

####### other methods
        ### NOTE DRAWING ON ROOM
    def draw(self,screen):
	if self.flag == 0:
            	screen.scr.blit(self.images[0], (self.x, self.y))
		return
        self.counter += 1

        if self.counter >= 80:
            ###self.counter = 80
            screen.scr.blit(self.images[7], (self.x, self.y))
            if self.counter <= 180:
		screen.scr.blit(self.images[8], (self.x+5, self.y-40))
	    else:
		self.counter = 200
	    return

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x, self.y))
        elif self.counter < 60:
            screen.scr.blit(self.images[5], (self.x, self.y))
        elif self.counter < 70:
            screen.scr.blit(self.images[6], (self.x, self.y))
        elif self.counter < 80:
            screen.scr.blit(self.images[7], (self.x, self.y))
        ### NOTE DRAWING IN MAPROOM
    def drawonmap(self, screen, maproom):
	if self.flag == 0:
            	screen.scr.blit(self.images[0], (self.x+maproom.relativex, self.y+maproom.relativey))
		return
        self.counter += 1

        if self.counter >= 80:
            ###self.counter = 80
            screen.scr.blit(self.images[7], (self.x+maproom.relativex, self.y+maproom.relativey))
            if self.counter <= 180:
		screen.scr.blit(self.images[8], (self.x+maproom.relativex+5, self.y+maproom.relativey-40))
	    else:
		self.counter = 200
	    return

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 60:
            screen.scr.blit(self.images[5], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 70:
            screen.scr.blit(self.images[6], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 80:
            screen.scr.blit(self.images[7], (self.x+maproom.relativex, self.y+maproom.relativey))
        

    def getname(self,text):
        return text.getchestname()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from chest1 import *

### This chest contains a mana potion
class Chestmanapotion(Chest1):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Chest1.__init__(self,x,y,w,h,dungeonnumber,keynumber)
        self.images = []
        self.addimage('chest1.bmp',0,0,0)
        self.addimage('chest2.bmp',0,0,0)
        self.addimage('chest3.bmp',0,0,0)
        self.addimage('chest4.bmp',0,0,0)
        self.addimage('chest5.bmp',0,0,0)
        self.addimage('chest6.bmp',0,0,0)
        self.addimage('chest7.bmp',0,0,0)
        self.addimage('chest8.bmp',0,0,0)
	self.addimage('chestmanapotioncontents.bmp',0,0,0)

    def remove(self,list):
        string = "You have a chest "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

	if self.flag == 1:
		return None
	self.flag = 1
        ###if Utilities().readandfindstring(string):
        ###    list.remove(self)
       	###    return None
 
        f = open("./workfile",'r')
        for line in f:
            s += line
        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

	return 1 

    def readkeys(self, list):
        string = "You have a chest "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            ###print "+++ Chest mana potion registered"
	    ### NOTE : do not remove, only after drinking remove
            #if list:
            #    list.remove(self)
            return None ### None 

	return 1 ### None? 
 
    def readkeys2(self, list):
        string = "You drank the mana potion - chest 2"
        string += "\n"

        if Utilities().readandfindstring(string):
            ### print "+++ Chest mana potion contents registered"
            ###if list:
            ###    list.remove(self)
            return None 

	return 1

####### other methods

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemdemon1 import *

class Demon1(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemdemon1())
        self.addimage('demon11.bmp',255,255,255)
        self.addimage('demon11.bmp',255,255,255)
        self.addimage('demon11.bmp',255,255,255)
        self.addimage('demon11.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getdemon1name()

#    def gettalk(self):
#        talksystem.gettalk(self)

    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the demon."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemdjinnofnootie import *
from entityfactory import *
from food import *

class Djinnofnootie(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemdjinnofnootie())
        self.addimage('djinnofnootie1.bmp',0,0,0)
        self.addimage('djinnofnootie2.bmp',0,0,0)
        self.addimage('djinnofnootie3.bmp',0,0,0)
        self.addimage('djinnofnootie4.bmp',0,0,0)
        self.counter = 0

	self.direction = 1 

####### TEXT / FONT interface
    def getname(self,text):
        return text.getdjinnofnootiename()

#    def gettalk(self):
#        talksystem.gettalk(self)
#    def update(self,room):
#	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The djinnofnootie drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the djinnofnootie."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room
	1

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from entity import *
import random
from spellbookdracolich import *
from utility import *

class Dracolich(Enemytalking):#FIXME emytalking):
    "Dungeon 1 boss"
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):#FIXME spellbooknumber
        Enemytalking.__init__(self,x,y,w,h,None)

        self.addimage('dracolich1.bmp',0,0,0)
        self.addimage('dracolich2.bmp',0,0,0)
        self.addimage('dracolich3.bmp',0,0,0)
        self.addimage('dracolich4.bmp',0,0,0)
        self.addimage('dracolich3.bmp',0,0,0)
        self.addimage('dracolich2.bmp',0,0,0)

        self.addimage('dracolichcast1.bmp',0,0,0)
        
        self.counter = 0
        self.direction = "south"
        self.hitpoints = 1

        self.casting = None
        self.castingcounter = 0

        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber

        self.spellbookx = 100
        self.spellbooky = 100
        self.spellbook = Spellbookdracolich(self.spellbookx,self.spellbooky,80,80,dungeonnumber,keynumber)


    def draw(self,screen):

        r3 = randint(0,450)
        if r3 < 1:
            self.casting = 1

        if self.casting:
            if self.castingcounter < 10:
                self.castingcounter += 1
                screen.scr.blit(self.images[6], (self.x, self.y))
                return

        self.counter += 1

        if self.counter > 70:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x, self.y))
        elif self.counter < 60:
            screen.scr.blit(self.images[5], (self.x, self.y))
        else:
            screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):

        if self.casting:
            if self.castingcounter >= 10:
                self.casting = None
                self.castingcounter = 0
                level.summonskeleton(self.x-50,self.y+50)
            


        r = randint(0,100)

        if r < 1:
            r2 = randint(0,3)
            if r2 == 0:
                self.direction = "north"
            if r2 == 1:
                self.direction = "south"
            if r2 == 2:
                self.direction = "west"
            if r2 == 3:
                self.direction = "east"

        if self.collisionlist(self,level.entities) != self or self.collisionlist(self,level.exits) or self.collisionlist(self,level.boxes):#FIXME != self
            print "dracolich entity bounce back"
            self.bounceback()
	    return

        if self.direction == "north":
            self.y -= 1
        if self.direction == "south":
            self.y += 1
        if self.direction == "west":
            self.x -= 1
        if self.direction == "east":
            self.x += 1
        
            

    def bounceback(self):
        if self.direction == "north":
            self.y += 5
            self.direction = "south"
            #self.movedown()
        elif self.direction == "south":
            self.y -= 5
            self.direction = "north"
            #self.moveup()
        elif self.direction == "west":
            self.x += 5
            self.direction = "esst"
            #self.moveright()
        elif self.direction == "east":
            self.x -= 5
            self.direction = "west"
            #self.moveleft()

    def remove(self,list):
#        string = "You have killed boss 1 - dungeon 2\n"




        string = "You have killed boss "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"
            
        s = ""

        if Utilities().readandfindstring(string):
            list.addobject(self.spellbook)
            list.remove(self)
            return None


        if self.hitpoints == 0:

            f = open("./workfile",'r')
            for line in f:
                s += line
                
            f = open("./workfile",'w')
            
            f.write(s)
            f.write(string)
            f.write("\n")

            list.addobject(self.spellbook)
            list.remove(self)

            return 1

    def hit(self):
        self.hitpoints -= self.decreasehp


    def readboss(self,list):
        string = "You have killed boss "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ boss already neutralised"
#            self.removeallenemies()
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getdracolichname()
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *
import random

class Dragon(Enemy):
    def __init__(self,id,screen,x,y,w,h):
        Enemy.__init__(self,id,screen,x,y,w,h)

        self.addimage('dragon1.bmp',0,0,0)
#         self.addimage('skeleton2.bmp',0,0,0)
#         self.addimage('skeleton3.bmp',0,0,0)
#         self.addimage('skeleton4.bmp',0,0,0)
#         self.addimage('skeleton5.bmp',0,0,0)

        self.counter = 0
        self.direction = "south"
        self.hitpoints = 5

    def draw(self,level):
        level.screen.blit(self.images[0], (self.x, self.y))
#         self.counter += 1

#         if self.counter > 60:
#             self.counter = 0

#         if self.counter < 10:
#             level.screen.blit(self.images[0], (self.x, self.y))
#         elif self.counter < 20:
#             level.screen.blit(self.images[1], (self.x, self.y))
#         elif self.counter < 30:
#             level.screen.blit(self.images[2], (self.x, self.y))
#         elif self.counter < 40:
#             level.screen.blit(self.images[3], (self.x, self.y))
#         elif self.counter < 50:
#             level.screen.blit(self.images[4], (self.x, self.y))
#         else:
#             level.screen.blit(self.images[0], (self.x, self.y))

    def update(self,level):

        r = randint(0,100)

        if r < 5:
            r2 = randint(0,3)
            if r2 == 0:
                self.direction = "north"
            if r2 == 1:
                self.direction = "south"
            if r2 == 2:
                self.direction = "west"
            if r2 == 3:
                self.direction = "east"


        if level.collisionenemywithentities(self) or level.collisionenemywithboxes(self) or level.collisionenemywithexits(self):
            print "entity bounce back"
            self.bounceback()
            self.bounceback()
            self.bounceback()
            r3 = randint(0,3)
            if r3 == 0:
                self.direction = "north"
            if r3 == 1:
                self.direction = "south"
            if r3 == 2:
                self.direction = "west"
            if r3 == 3:
                self.direction = "east"


        if self.direction == "north":
            self.y -= 1
        if self.direction == "south":
            self.y += 1
        if self.direction == "west":
            self.x -= 1
        if self.direction == "east":
            self.x += 1
        
    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemearthweird import *

class Earthweird(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemearthweird())
        self.addimage('earthweird1.bmp',0,0,0)

    def getname(self,text):
        return text.getearthweirdname()


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from entity import *

class Enemy(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)

        self.decreasehp = 1
        self.hitpoints = 1

        self.direction = "north"

    def hit(self):
        r = randint(0,20)
        if r >= 1:
            print "hit"
            self.hitpoints -= self.decreasehp
        else:
            print "miss"
        
    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def bounceback(self):
        if self.direction == "north":
            self.y += 2 
            #FIXME self.direction = "south"
        elif self.direction == "south":
            self.y -= 2
            #self.moveup()
        elif self.direction == "west":
            self.x += 2
            #self.moveright()
        elif self.direction == "east":
            self.x -= 2
            #self.moveleft()


    def decreasehpinplayer(self, player, level):
	player.decreasehp(level)	
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Enemytalking(Enemy):
    def __init__(self,x,y,w,h,talksystem):
        Enemy.__init__(self,x,y,w,h)
        self.talksystem = talksystem
        self.talkcounter = 0
        self.currenttext = ""

    def leftbuttonpressed(self,game):
        if game.mouse.press(0) == 1:
            self.talkcounter += 1
            if self.talkcounter == 1:
                self.currenttext = self.talksystem.gettalk(game.text)#foo
            return self.currenttext
        else:
            self.talkcounter = 0 	
            return self.currenttext

    def leftbuttonpressedwithinventoryitem(self,game):
        if game.mouse.press(0) == 1:
            self.talkcounter += 1
	    baztext = ""
            if game.inventoryitem:
                baztext = game.inventoryitem.use(self,game)
            return baztext 
        else:
            self.talkcounter = 0 	
            return None#self.currenttext

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from hermit import *
from candleflame1 import *
from candleflame2 import *
from bat import *
from skeleton import *
from skeleton2 import *
from skeletonunderplayercommand import *
from tree2 import *
from tree3 import *
from tree4 import *
from tree5 import *
from tree6 import *
from toadstool import *
from ent import *
from chaosknight1 import *
from chaosknight2 import *
from myconid import *
from myconidred import *
from earthweird import *
from koboldmage import *
from shieldmaiden1 import *
from orcpaladin import *
from orcswordsmanblue import *
from angel import *
from hobgoblinswordsman1 import * 
from hobgoblinswordsmanchief1 import * 
from demon1 import *
from movingplatform1 import *
from movingplatformmaproom1 import *
from cherubstatue1 import *
from food import *
from batcrazy import *
from bouncer import *
from knightdark1 import *
from houndarchon import *
from oozebig import *
from waterdevil import *
from waterdevilfemale import *
from treestone import *
from treestonewithcandles import *
from nutter import *
from nutter2 import *
from nutter3 import *
from nutter4 import *
from nutternootie import *
from birdsparrow import *
from trollblack import *
from unicornstatue import *
from unicornstatuelittle import *
from blimp import *
from ghoststory import *
from chest1 import *
from orcguardian import *
from orcguardian2 import *
from goblinguardian import *
from djinnofnootie import *
from entstone import *
from knightgrey import *
from assassin import *
from assassinqueen import *

class Entityfactory(object):
    
    def makewithscreen(self, entityType,x,y,w,h, screen):
        classByType = {
            Entity.ENTITY_NUTTERNOOTIE : NutterNootie,
        }
        return classByType[entityType](x,y,w,h, screen)

    def makewithboxes(self, entityType,x,y,w,h, boxes):
        classByType = {
            Entity.ENTITY_BOUNCER1 : Bouncer,
            Entity.ENTITY_OOZEBIG1 : Oozebig,
            Entity.ENTITY_WATERDEVIL : Waterdevil,
            Entity.ENTITY_TROLLBLACK : Trollblack,
            Entity.ENTITY_ORCSWORDSMANBLUE : Orcswordsmanblue,
            Entity.ENTITY_CHAOSKNIGHT1 : Chaosknight1,
            Entity.ENTITY_CHAOSKNIGHT2 : Chaosknight2,
            Entity.ENTITY_ORCGUARDIAN : Orcguardian,
            Entity.ENTITY_ORCGUARDIAN2 : Orcguardian2,
            Entity.ENTITY_GOBLINGUARDIAN : Goblinguardian,
            Entity.ENTITY_KNIGHTGREY : Knightgrey,
            Entity.ENTITY_ASSASSIN : Assassin,
            Entity.ENTITY_ASSASSINQUEEN : Assassinqueen,
        }
        return classByType[entityType](x,y,w,h, boxes)

    def make(self, entityType,x,y,w,h):
        classByType = {
            Entity.ENTITY_BAT: Bat,
            Entity.ENTITY_SKELETON: Skeleton,
            Entity.ENTITY_SKELETON2: Skeleton2,
            Entity.ENTITY_SKELETONUNDERPLAYERCOMMAND: Skeletonunderplayercommand,
            Entity.ENTITY_TREE2 : Tree2,
            Entity.ENTITY_TREE3 : Tree3, 	
            Entity.ENTITY_TREE4 : Tree4, 
            Entity.ENTITY_TREE5 : Tree5, 
            Entity.ENTITY_TREE6 : Tree6, 
            Entity.ENTITY_TREESTONE : Treestone, 
            Entity.ENTITY_ENSORCELLEDTREE : Treestonewithcandles,
            Entity.ENTITY_ENT : Ent,
            Entity.ENTITY_MYCONID : Myconid,
            Entity.ENTITY_MYCONID_RED : Myconidred,
            Entity.ENTITY_EARTHWEIRD : Earthweird,
            Entity.ENTITY_KOBOLDMAGE : Koboldmage,
            Entity.ENTITY_ORCPALADIN : Orcpaladin,
            Entity.ENTITY_HOBGOBLINSWORDSMAN1 : Hobgoblinswordsman1,
            Entity.ENTITY_HOBGOBLINSWORDSMANCHIEF1 : Hobgoblinswordsmanchief1,
            Entity.ENTITY_ANGEL : Angel,
            Entity.ENTITY_DEMON1 : Demon1,
            Entity.ENTITY_PLATFORM1 : Movingplatform1,
            Entity.ENTITY_PLATFORMMAPROOM1 : Movingplatformmaproom1,
            Entity.ENTITY_CHERUBSTATUE1 : Cherubstatue1,
            Entity.ENTITY_FOOD : Food,
            Entity.ENTITY_BATCRAZY : Batcrazy,
            Entity.ENTITY_KNIGHTDARK1 : Knightdark,
            Entity.ENTITY_HOUNDARCHON1 : Houndarchon,
            Entity.ENTITY_WATERDEVILFEMALE : Waterdevilfemale,
            Entity.ENTITY_NUTTER1 : Nutter,
            Entity.ENTITY_NUTTER2 : Nutter2,
            Entity.ENTITY_NUTTER3 : Nutter3,
            Entity.ENTITY_NUTTER4 : Nutter4,
            Entity.ENTITY_SPARROW : Birdsparrow,
            Entity.ENTITY_UNICORNSTATUE : Unicornstatue,
            Entity.ENTITY_UNICORNSTATUELITTLE : Unicornstatuelittle,
            Entity.ENTITY_HERMIT : Hermit,
            Entity.ENTITY_CANDLEFLAME1 : Candleflame1,
            Entity.ENTITY_CANDLEFLAME2 : Candleflame2,
            Entity.ENTITY_SHIELDMAIDEN : Shieldmaiden,
        ###    Entity.ENTITY_NUTTERNOOTIE : NutterNootie,
            Entity.ENTITY_BLIMP : Blimp,
            Entity.ENTITY_GHOSTSTORY : Ghoststory,
            Entity.ENTITY_CHEST1 : Chest1,
            Entity.ENTITY_DJINNOFNOOTIE : Djinnofnootie,
            Entity.ENTITY_TOADSTOOL : Toadstool,
            Entity.ENTITY_ENTSTONE : Entstone,
        }
        return classByType[entityType](x,y,w,h)

    def add(self,room):
        room.entityfactory = self


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from random import *
import os
from utility import *

class Entity(object):


    ENTITY_BAT, ENTITY_SKELETON,ENTITY_SKELETON2, ENTITY_SKELETONUNDERPLAYERCOMMAND, ENTITY_TREE2,ENTITY_TREE3,ENTITY_TREE4,ENTITY_TREE5,ENTITY_TREE6,ENTITY_ENT,ENTITY_MYCONID,ENTITY_MYCONID_RED,ENTITY_EARTHWEIRD,ENTITY_KOBOLDMAGE,ENTITY_ORCPALADIN,ENTITY_ANGEL,ENTITY_HOBGOBLINSWORDSMAN1,ENTITY_DEMON1,ENTITY_HOBGOBLINSWORDSMANCHIEF1,ENTITY_PLATFORM1,ENTITY_PLATFORMMAPROOM1,ENTITY_CHERUBSTATUE1,ENTITY_FOOD,ENTITY_BATCRAZY,ENTITY_BOUNCER1,ENTITY_KNIGHTDARK1,ENTITY_HOUNDARCHON1,ENTITY_OOZEBIG1,ENTITY_WATERDEVIL,ENTITY_WATERDEVILFEMALE,ENTITY_TREESTONE,ENTITY_ENSORCELLEDTREE,ENTITY_NUTTER1,ENTITY_SPARROW,ENTITY_NUTTER2,ENTITY_NUTTER3,ENTITY_NUTTER4,ENTITY_TROLLBLACK,ENTITY_UNICORNSTATUE,ENTITY_UNICORNSTATUELITTLE,ENTITY_HERMIT,ENTITY_CANDLEFLAME1,ENTITY_CANDLEFLAME2,ENTITY_ORCSWORDSMANBLUE,ENTITY_SHIELDMAIDEN,ENTITY_NUTTERNOOTIE,ENTITY_CHAOSKNIGHT1,ENTITY_CHAOSKNIGHT2,ENTITY_BLIMP,ENTITY_GHOSTSTORY,ENTITY_CHEST1,ENTITY_ORCGUARDIAN,ENTITY_ORCGUARDIAN2,ENTITY_DJINNOFNOOTIE,ENTITY_TOADSTOOL,ENTITY_ENTSTONE,ENTITY_GOBLINGUARDIAN,ENTITY_KNIGHTGREY,ENTITY_ASSASSIN,ENTITY_ASSASSINQUEEN = xrange(60)

    def __init__(self,x,y,w,h):
        self.x = x
        self.y = y
        self.w = w
        self.h = h

	self.entangled = 0 

        self.images = []
        self.imagescounter = 0
        self.maximages = 0
        
        self.talksystem = None

	#self.platform = 0
	self.talkcounter = 0 ### NOTE DUMMY
	self.hitpoints = 100#FIXME in entities like trees
#NOTE        self.name = "Entity"

    def doplatform(self,player,level):
	1

    def dofood(self,player):
	1

    def leftbuttonpressed(self,game):#,mouse,text,press0):
        print "+++ left button press on entity"
        return None

    def leftbuttonpressedwithinventoryitem(self,game):
        print "+++ left button press on entity with inventory item"
        if game.mouse.press(0):
            return 1
        return None


    def middlebuttonpressed(self,mouse):
        1

    def rightbuttonpressed(self,mouse):
        1


    def getname(self,text):
        text.getname(self)

    def getnametext(self,text):
        return "Entity"

    def addimage(self,filename,r,g,b):# rgb transparency values
        self.maximages += 1

        image = pygame.image.load(filename).convert()
        image.set_colorkey((r,g,b))
        self.images.append(image)
        
#    def auxdraw(self):
#	self.auxdraw(self)

    def draw(self,screen):
        self.imagescounter += 1
        if self.imagescounter == self.maximages:
            self.imagescounter = 0     
        screen.scr.blit(self.images[self.imagescounter], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))

    def drawonmap(self, screen, maproom):
        self.imagescounter += 1
        if self.imagescounter == self.maximages:
            self.imagescounter = 0     
        screen.scr.blit(self.images[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))

    
    def update(self,room):#FIXME all level arg must be room

	if self.entangled:
		return

        r = randint(0,3)
        if r == 0:
            self.x += 1
        if r == 1:
            self.x -= 1
        if r == 2:
            self.y += 1
        if r == 3:
            self.y -= 1

    def decreasehpinplayer(self, player, level):
	1	
    
    def hit(self):
        1

    def bounceback(self):
        1

    def remove(self,list):
        1

    def deathupdate(self):
        1

    def destroy(self):
        1

    def collisionlist(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            if o and collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h:   	
                return o
        return None

    def addtolist(self,list):
        list.addobject(self)

    def isskeleton(self):
        return None

    def isplayerskeleton(self):
        return None

    def usebomb(self,game):
        ### game.screen.scr.blit(game.font.render("Nothing happens", 16, (255,255,255)), (10,10))
        return game.text.getnothinghappens()

    def usekey(self,game):
        return game.text.getnothinghappens()

    # FIXME enemy
    def usedracolichspellbook(self,game):
        ### game.screen.scr.blit(game.font.render("Nothing happens", 16, (255,255,255)), (10,10))
        return game.text.getnothinghappens()
        #self.setblackplayer(game)
        #FIXME type(Player)
        
    def usenootiespellbook(self,game):
        return game.text.getnothinghappens()

    def usedracolichspellbookonentity(self,game):
        ### game.screen.scr.blit(game.font.render("Nothing happens", 16, (255,255,255)), (10,10))
        return game.text.getnothinghappens()
 
    def useyellowring(self,game):
        return game.text.getnothinghappens()
    
    def usescrollinvisibility(self,game):
        ### game.screen.scr.blit(game.font.render("Nothing happens!", 16, (255,255,255)), (10,10))
        return game.text.getnothinghappens()

    def usechest1(self,game):
        ### game.screen.scr.blit(game.font.render("Nothing happens!", 16, (255,255,255)), (10,10))
        return game.text.getnothinghappens()

    def usechestmanapotion(self,game):
        return game.text.getnothinghappens()

    def setblackplayer(self,game):
        print "+++ set black entity"
        1


	# FOR mouse CLICKS WITH ITEMS
    def leftbuttonpressedwithinventoryitem(self,game):
        if game.mouse.press(0) == 1:
            self.talkcounter += 1
            if game.inventoryitem:
                game.inventoryitem.use(self,game)#JUMP
            return 1
        else:
            self.talkcounter = 0 	
            return None#self.currenttext



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *
from random import *

class Ent(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h)
        self.addimage('ent2.bmp',0,0,0)
        self.addimage('ent3.bmp',0,0,0)
        self.addimage('ent4.bmp',0,0,0)
        self.addimage('ent5.bmp',0,0,0)
        self.addimage('ent6.bmp',0,0,0)
        self.counter =  0
        self.flag1 = 0

    def getname(self,text):
        return text.getentname()

    def update(self,level):
        1

    def draw(self,screen):

        self.counter += 1


        if self.counter > 600:
            self.counter = 0

        r = randint(0,4)

#        if r < 25:
        if self.flag1 == 0:
            if self.counter <= 200:
                screen.scr.blit(self.images[0], (self.x, self.y))
            elif self.counter <= 400 and self.counter > 200:
                screen.scr.blit(self.images[1], (self.x, self.y))
            elif self.counter <= 600 and self.counter > 400:
                screen.scr.blit(self.images[2], (self.x, self.y))
#            elif self.counter <= 600: 
#                screen.scr.blit(self.images[0], (self.x, self.y))
            else:
                screen.scr.blit(self.images[0], (self.x, self.y))
                self.counter = 0
#                self.flag1 = 1

        elif self.flag1 == 1:
            if self.counter <= 200:
                screen.scr.blit(self.images[0], (self.x, self.y))
            elif self.counter <= 400 and self.counter > 200:
                screen.scr.blit(self.images[3], (self.x, self.y))
            elif self.counter <= 600 and self.counter > 400:
                screen.scr.blit(self.images[4], (self.x, self.y))
            else:
                self.counter = 0
                self.flag1 = 0
                screen.scr.blit(self.images[0], (self.x, self.y))

#             r = randint(0,10)

#             if r == 10:
#                 r2 = randint(0,600)
#                 if r2 < 100:
#                     screen.scr.blit(self.images[0], (self.x, self.y))
#                 elif r2 < 200:
#                     screen.scr.blit(self.images[1], (self.x, self.y))
#                 elif r2 < 300:
#                     screen.scr.blit(self.images[2], (self.x, self.y))
#                 elif r2 < 400:
#                     screen.scr.blit(self.images[3], (self.x, self.y))
#                 elif r2 < 500:
#                     screen.scr.blit(self.images[4], (self.x, self.y))
#                 else:
#                     screen.scr.blit(self.images[0], (self.x, self.y))
#                     self.counter = 0
#                     self.flag1 = 0
#             else:
#                 screen.scr.blit(self.images[0], (self.x, self.y))



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *
from random import *

class Entstone(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h) 
        self.addimage('entstone2.bmp',0,0,0)
        self.addimage('entstone3.bmp',0,0,0)
        self.addimage('entstone4.bmp',0,0,0)
        self.addimage('entstone5.bmp',0,0,0)
        self.addimage('entstone6.bmp',0,0,0)
        self.counter =  0
        self.flag1 = 0

    def update(self,level):
        1

    def draw(self,screen):

        self.counter += 1


        if self.counter > 600:
            self.counter = 0

        r = randint(0,4)

#        if r < 25:
        if self.flag1 == 0:
            if self.counter <= 200:
                screen.scr.blit(self.images[0], (self.x, self.y))
            elif self.counter <= 400 and self.counter > 200:
                screen.scr.blit(self.images[1], (self.x, self.y))
            elif self.counter <= 600 and self.counter > 400:
                screen.scr.blit(self.images[2], (self.x, self.y))
#            elif self.counter <= 600: 
#                screen.scr.blit(self.images[0], (self.x, self.y))
            else:
                screen.scr.blit(self.images[0], (self.x, self.y))
                self.counter = 0
#                self.flag1 = 1

        elif self.flag1 == 1:
            if self.counter <= 200:
                screen.scr.blit(self.images[0], (self.x, self.y))
            elif self.counter <= 400 and self.counter > 200:
                screen.scr.blit(self.images[3], (self.x, self.y))
            elif self.counter <= 600 and self.counter > 400:
                screen.scr.blit(self.images[4], (self.x, self.y))
            else:
                self.counter = 0
                self.flag1 = 0
                screen.scr.blit(self.images[0], (self.x, self.y))

#             r = randint(0,10)

#             if r == 10:
#                 r2 = randint(0,600)
#                 if r2 < 100:
#                     screen.scr.blit(self.images[0], (self.x, self.y))
#                 elif r2 < 200:
#                     screen.scr.blit(self.images[1], (self.x, self.y))
#                 elif r2 < 300:
#                     screen.scr.blit(self.images[2], (self.x, self.y))
#                 elif r2 < 400:
#                     screen.scr.blit(self.images[3], (self.x, self.y))
#                 elif r2 < 500:
#                     screen.scr.blit(self.images[4], (self.x, self.y))
#                 else:
#                     screen.scr.blit(self.images[0], (self.x, self.y))
#                     self.counter = 0
#                     self.flag1 = 0
#             else:
#                 screen.scr.blit(self.images[0], (self.x, self.y))
    def getname(self,text):
        return text.getentstonename()


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from box import *

class Exitbox(Box):
    "exit box"
    def __init__(self,x,y,w,h,roomid,newx,newy,room):
        Box.__init__(self,x,y,w,h)
        
        self.roomid = roomid
        self.newx = newx
        self.newy = newy
        self.room = room

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Food(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
	if randint(0,1) == 0:
            self.addimage('food1.bmp',255,255,255)
        else:
            self.addimage('food2.bmp',255,255,255)

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    def remove(self,list):
	print ("You eat some food.\n")
        list.remove(self)
	return 1 
    
    def dofood(self,player):
	player.increasehp()
 
    def getname(self,text):
        return text.getfoodname()

    def leftbuttonpressed(self,game):
        return None 

    def use(self, e, game):
	print 'You used the food on %s' % e
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010
# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Gamepoints:
    "Main function"
    def __init__(self):
	self.points = 0
	self.talktobirdsparrow = 0
	self.usedracolichspellbookonnootie = 0
	self.gotkey21 = 0
	self.gotswordblue = 0
	self.gotscrollinvisibility = 0
	self.gotringyellow = 0
	self.gotspellbookdracolich = 0
	self.gotspellbooknootie = 0
	self.openedchest1 = 0
	self.openedchestmanapotion = 0

    def set(self,string):
	if string == "talkedtobirdsparrow" and self.talktobirdsparrow == 0:
		self.talkedtobirdsparrow = 1
		self.points += 3
	elif string == "usedracolichspellbookonnootie" and self.usedracolichspellbookonnootie == 0:
		self.usedracolichspellbookonnootie = 1
		self.points += 3
	elif string == "gotkey21" and self.gotkey21 == 0:
		self.gotkey21 = 1
		self.points += 5
	elif string == "gotswordblue" and self.gotswordblue == 0:
		self.gotswordblue = 1
		self.points += 5
	elif string == "gotscrollinvisibility" and self.gotscrollinvisibility == 0:
		self.gotscrollinvisibility = 1
		self.points += 5
	elif string == "gotringyellow" and self.gotringyellow == 0:
		self.gotringyellow = 1
		self.points += 5
	elif string == "gotspellbookdracolich" and self.gotspellbookdracolich == 0:
		self.gotspellbookdracolich = 1
		self.points += 5
	elif string == "gotspellbooknootie" and self.gotspellbooknootie == 0:
		self.gotspellbooknootie = 1
		self.points += 5
	elif string == "openedchest1" and self.openedchest1 == 0:
		self.openedchest1 = 1
		self.points += 2
	elif string == "openedchestmanapotion" and self.openedchestmanapotion == 0:
		self.openedchestmanapotion = 1
		self.points += 2
	else:
		1###print "Do not know the points of string=%s or already registered" % string	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from inventoryscrollinvisibility import *
from inventoryringyellow import *
from inventorychest1 import *
from inventorychestmanapotion import *
from inventoryseraphimsword import *
from chestmanapotion import *
from player import *
from level import *
from screen import *
from utility import *
from mouse import *
from textenglish import *
from textdutch import *
from spellschooser import *
from spellschooserspellbookdracolichsummonskeleton import *
from spellschooserspellbooknootieentangle import *
from inventory import *
from inventorykey import *
from inventoryspellbookdracolich import *
from inventoryspellbooknootie import *
from sword1blue import *
from scrollinvisibility import *
from gamepoints import *

class Game:
    "Main function"
    def __init__(self):
        pygame.init()
        pygame.font.init()
        self.font = pygame.font.SysFont("Vera", 32)
        self.scorefont = pygame.font.SysFont("Vera", 16)

	self.textstring = ""
	self.textstringcounter = 0
	
	self.gamepoints = Gamepoints() 
	self.video = None
        self.language = "english"
        
        if self.language == "english":
            self.text = Textenglish()
        elif self.language == "dutch":
            self.text = Textdutch()

        self.screen = Screen()
        self.mouse = Mouse()
        
	self.spellschooseritem = None

        self.inventoryitem = None
	self.clickcounter = 0
        self.player = Player()
        self.level = Level(self.screen)
        #FIXME1 loading time
	self.swordplay = 0

        self.setblackplayer()
        ### self.player.setinvisibleplayer(self)
        blankimage = pygame.image.load('blank.bmp').convert()
        lifebarimage = pygame.image.load('lifebar1.bmp').convert()
        manabarimage = pygame.image.load('manabar1.bmp').convert()
        inventoryimage = pygame.image.load('inventoryimage1.bmp').convert()
        openinventoryimage = pygame.image.load('inventoryimage2.bmp').convert()
        spellschooserimage = pygame.image.load('spellschooser1.bmp').convert()
        openspellschooserimage = pygame.image.load('spellschooser2.bmp').convert()

        introductionimage = pygame.image.load('koboldface1.bmp').convert()
	introductionflag = 0
	while introductionflag == 0:
		for e in pygame.event.get():
       			if pygame.mouse.get_pressed()[0]:
				introductionflag = 1
				break
       			else: 
       				self.screen.scr.blit(self.font.render("The magical winds are foul here.", 8, (255,255,255)), (140,320))
       				self.screen.scr.blit(self.font.render("I better be on my way...", 8, (255,255,255)), (140,350))
				self.screen.scr.blit(introductionimage, (20,320))
			pygame.display.update()
	# NOTE duplicate mousex mousey
	position = pygame.mouse.get_pos()
       	mousex = position[0]
       	mousey = position[1]
	


        while self.level.gameover == 0:

            if Key(0,0,0,0,"2","1").readkeys(None):
	    ###if temp.flag > 0:
                self.gamepoints.set("gotkey21")
            if Sword1blue(0,0,0,0,"3","1").readkeys(None):
                self.gamepoints.set("gotswordblue")
            if Scrollinvisibility(0,0,0,0,"3","1").readkeys(None):
                self.gamepoints.set("gotscrollinvisibility")
            if Ringyellow(0,0,0,0,"3","1").readkeys(None):
                self.gamepoints.set("gotringyellow")
	    chest1 = Chest1(0,0,0,0,"3","3")
            if not chest1.readkeys(None): 
                self.gamepoints.set("openedchest1")
	    chestmanapotion = Chestmanapotion(0,0,0,0,"3","2")
            if not chestmanapotion.readkeys(None): 
                self.gamepoints.set("openedchestmanapotion")
            if Spellbookdracolich(0,0,0,0,"2","1").readspellbook(None) and not Spellbookdracolich(0,0,0,0,"2","1").readdestroyspellbook(None):
                self.gamepoints.set("gotspellbookdracolich")
            if Spellbooknootie(0,0,0,0,"3","1").readspellbook(None):
                self.gamepoints.set("gotspellbooknootie")

            for event in pygame.event.get():
		self.clickcounter -= 1
		position = pygame.mouse.get_pos()
        	mousex = position[0]
        	mousey = position[1]

                if event.type == QUIT:
                    return
                elif event.type == KEYDOWN:

                    if event.key == K_UP:
                       if self.level.roommanager.room.collisionboxes(self.player):
                           self.player.bounceback(self.level)
                           print "Collision player with box"
                       elif self.level.roommanager.room.collisiontriboxes1(self.player):
                        print "Collision player with tri box"
                        self.player.movedown()
                        self.player.movedown()
                       elif self.level.roommanager.room.collisiontriboxes2(self.player):
                        print "Collision player with tri box"
                        self.player.movedown()
                        self.player.movedown()
                       else:
                        self.player.moveupanddirect(self.level)
                    if event.key == K_DOWN:
                       if self.level.roommanager.room.collisionboxes(self.player):
                           self.player.bounceback(self.level)
                           print "Collision player with box"
                       elif self.level.roommanager.room.collisiontriboxes1(self.player):
                        self.player.moveup()
                        self.player.moveup()
                        print "Collision player with tri box"
                       elif self.level.roommanager.room.collisiontriboxes2(self.player):
                        self.player.moveup()
                        self.player.moveup()
                        print "Collision player with tri box"
                       else:
                        self.player.movedownanddirect(self.level)
                    if event.key == K_LEFT:
                       if self.level.roommanager.room.collisionboxes(self.player):
                           self.player.bounceback(self.level)
                           print "Collision player with box"
                       elif self.level.roommanager.room.collisiontriboxes1(self.player):
                        print "Collision player with tri box"
                        self.player.moveright()
                        self.player.moveright()
                       elif self.level.roommanager.room.collisiontriboxes2(self.player):
                        print "Collision player with tri box"
                        self.player.moveright()
                        self.player.moveright()
                       else:
                        self.player.moveleftanddirect(self.level)
                    if event.key == K_RIGHT:
                       if self.level.roommanager.room.collisionboxes(self.player):
                           self.player.bounceback(self.level)
                           print "Collision player with box"

                       elif self.level.roommanager.room.collisiontriboxes1(self.player):
                        print "Collision player with tri box"
                        self.player.moveleft()
                        self.player.moveleft()
                       elif self.level.roommanager.room.collisiontriboxes2(self.player):
                        print "Collision player with tri box"
                        self.player.moveleft()
                        self.player.moveleft()
                       else:
                        self.player.moverightanddirect(self.level)
#FIXME slight touch                    elif event.key == K_RETURN:
#                        self.inventoryitem = None
                        
                    elif event.key == K_b:
                        self.player.dropbomb(self.level)
                        print "drop bomb"
			
                    elif event.key == K_SPACE:
                	if Sword1blue(0,0,0,0,"3","1").readkeys(None):
                 		self.swordplay = 1
             #if self.swordplay != 0:
                  		self.swordplay += 1
                         #self.player.dropbomb(self.level)
                       	        print "fight with sword"
		if (event.type == KEYDOWN and event.key == K_u) or (self.mouse.press(0) and mousex > 600 and mousex < 640 and mousey > 0 and mousey < 40):
                        flag = 0
                        inventory = Inventory()

                        if Key(0,0,0,0,"2","1").readkeys(None):
                            inventory.additem(Inventorykey())
                        if Sword1blue(0,0,0,0,"3","1").readkeys(None):
                            inventory.additem(Inventoryseraphimsword())
             		    self.swordplay = 1
                        if Scrollinvisibility(0,0,0,0,"3","1").readkeys(None):
                            inventory.additem(Inventoryscrollinvisibility())
                        if Ringyellow(0,0,0,0,"3","1").readkeys(None):
                            inventory.additem(Inventoryringyellow())
			chest1 = Chest1(0,0,0,0,"3","3")
                        if not chest1.readkeys(None): 
			    if chest1.readkeys2(None):
                                inventory.additem(Inventorychest1())
			chestmanapotion1 = Chestmanapotion(0,0,0,0,"3","2")
                        if not chestmanapotion1.readkeys(None): 
			    if chestmanapotion1.readkeys2(None):
                                inventory.additem(Inventorychestmanapotion())
                        if Spellbookdracolich(0,0,0,0,"2","1").readspellbook(None) and not Spellbookdracolich(0,0,0,0,"2","1").readdestroyspellbook(None):
                            inventory.additem(Inventoryspellbookdracolich())
                        if Spellbooknootie(0,0,0,0,"3","1").readspellbook(None):
                            inventory.additem(Inventoryspellbooknootie())
		          

                        while flag == 0:#NOTE1
                            for event in pygame.event.get():
                                if event.type == QUIT:
                                    return
                                
                                elif event.type == KEYDOWN:
                                    if event.key == K_LEFT:
                                        inventory.moveleft()
                                    elif event.key == K_RIGHT:
                                        inventory.moveright()
                                    elif event.key == K_RETURN:
                                        self.inventoryitem = inventory.getitem(self.inventoryitem)
                                        
                                        self.level.gameover = 0
                                        flag = 1
				elif self.mouse.press(0):
					self.inventoryitem = inventory.getinventoryitemwithmouse(self.inventoryitem, self.mouse)	
                                        self.level.gameover = 0
                                        flag = 1
                            		for e in pygame.event.get():
        				    if  not pygame.mouse.get_pressed()[0]:
						break
                                	    else:
						pygame.display.update()
					self.clickcounter = 2 


                                inventory.draw(self.screen)
                                pygame.display.update()
		### Casting - spells choosers
		if (event.type == KEYDOWN and event.key == K_s) or (self.mouse.press(0) and mousex > 560 and mousex < 600 and mousey > 0 and mousey < 40):
                        flag = 0
			spellschooser = SpellsChooser()

                        ###if Scrollinvisibility(0,0,0,0,"3","1").readkeys(None):
                        ###    inventory.additem(Inventoryscrollinvisibility())
			
			### add summon skeleton spell
                        if Spellbookdracolich(0,0,0,0,"2","1").readspellbook(None) and not Spellbookdracolich(0,0,0,0,"2","1").readdestroyspellbook(None):
                            spellschooser.additem(Spellschooserspellbookdracolichsummonskeleton())
                        if Spellbooknootie(0,0,0,0,"3","1").readspellbook(None):
                            spellschooser.additem(Spellschooserspellbooknootieentangle())
		          

                        while flag == 0:#NOTE1
                            for event in pygame.event.get():
                                if event.type == QUIT:
                                    return
                                
                                elif event.type == KEYDOWN:
                                    if event.key == K_LEFT:
                                        inventory.moveleft()
                                    elif event.key == K_RIGHT:
                                        inventory.moveright()
                                    elif event.key == K_RETURN:
                                        self.spellschooseritem = inventory.getitem(self.spellschooseritem)
                                        
                                        self.level.gameover = 0
                                        flag = 1
				elif self.mouse.press(0):
					self.spellschooseritem = spellschooser.getitemwithmouse(self.spellschooseritem, self.mouse)	
                                        self.level.gameover = 0
                                        flag = 1
                            		for e in pygame.event.get():
        				    if  not pygame.mouse.get_pressed()[0]:
						break
                                	    else:
						pygame.display.update()
					self.clickcounter = 2 


                                spellschooser.draw(self.screen)
                                pygame.display.update()


            self.level.roommanager.room.collisionexits(self.player,self.level.roommanager)
            self.level.roommanager.room.update(self.player,self.level, self.swordplay)                
            self.level.roommanager.room.draw(self.screen)
            self.screen.scr.blit(self.player.draw(), (self.player.x,self.player.y))

	    ### TOP BARS & SCORE
            self.screen.scr.blit(lifebarimage, (8,0))
            self.player.drawlife(self.screen)
            self.screen.scr.blit(manabarimage, (8,22))
            self.player.drawmana(self.screen)
	    if mousex > 600 and mousex < 640 and mousey > 0 and mousey < 40:
            	self.screen.scr.blit(self.font.render("Open Inventory", 8, (255,255,255)), (270,220))
		self.screen.scr.blit(openinventoryimage, (600,0))
            else:
		self.screen.scr.blit(inventoryimage, (600,0))
	    if mousex > 560 and mousex < 600 and mousey > 0 and mousey < 40:
            	self.screen.scr.blit(self.font.render("Cast Spell", 8, (255,255,255)), (270,220))
		self.screen.scr.blit(openspellschooserimage, (560,0))
            else:
		self.screen.scr.blit(spellschooserimage, (560,0))
	    gamepointsstring = "Score : %d" % self.gamepoints.points
            self.screen.scr.blit(self.scorefont.render(gamepointsstring, 8, (255,255,255)), (500,10))

            # DISPLAY ENTITY NAMES
            if self.swordplay < 2 and self.swordplay > 0:           
	      	if self.player.direction == "north" or self.player.direction == "west": 
                     self.screen.scr.blit(self.player.drawswordleft(), (self.player.x,self.player.y))
	        else:	
                     self.screen.scr.blit(self.player.drawswordright(), (self.player.x,self.player.y))
            if self.swordplay >= 2:
          	self.swordplay = 0
            if self.swordplay == 0:         
                 self.screen.scr.blit(self.player.draw(), (self.player.x,self.player.y))

            self.mouse.update()
            self.mouse.draw(self.screen,self.inventoryitem)
            
            # FIXME1 maproom
	    ### self.clickcounter -= 1 
	    if self.inventoryitem and self.clickcounter <= 0:
		self.clickcounter = 0
         	bartext = self.level.roommanager.room.domouseinventory(self)
		if bartext and bartext != "" and bartext != 1:
		    # print "+++ returned bartext = %s" % bartext
		    self.textstring = bartext
		    self.textstringcounter = 120 
                if bartext == 1:
		    self.inventoryitem = None
            else:##FIXME indent:
		self.level.roommanager.room.domouse(self)#self.screen, self.mouse,font1,self.text,self.player)
		
	    if self.spellschooseritem:
		self.spellschooseritem.cast(self)
		self.spellschooseritem = None

	    if self.textstringcounter > 0:
		self.textstringcounter -= 1
                self.screen.scr.blit(self.font.render(self.textstring, 16, (255,255,255)), (20,300))
		
	    if self.video:
		self.video.play(self)

            pygame.display.update()
        

            pygame.display.update()
            self.screen.scr.blit(blankimage, (0,0))
        
        while 1: 
            image1 = pygame.image.load('gameover1.bmp').convert()
            self.screen.scr.blit(image1, (0,0))
            pygame.display.update()
        
        

    def setblackplayer(self):
        string = "You have used the dracolich's spellbook on yourself\n"
        s = ""

        if Utilities().readandfindstring(string):
            self.player.setblackplayer(self)
            return

        if not Utilities().readandfindstring(string):
                    
            f = open("./workfile",'r')
            for line in f:
                s += line
                
                f = open("./workfile",'w')
        
                f.write(s)
                f.write(string)
                f.write("\n")
                

    def domouseonplayer(self,room):
        return room.collisionplayer(self.mouse,self.player)

    def domouseonplayerrelative(self,room):
        return room.collisionplayerrelative(self.mouse,self.player,room.relativex,room.relativey)

    def leftbuttonpressed(self,o):
        self.previoustext = o.leftbuttonpressed(self)#self,game.text,self.press(0))
        return self.previoustext
                        
    def collisionlistonmouse(self,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            if o:
		x = o.x
            	y = o.y
            	mx = self.mouse.x###FIXME self.processorrelativex(self.mouse,x)
            	my = self.mouse.y
            	if o and mx >= x and mx <= x + o.w and my >= y and my <= y + o.h: 
                	return o
        return None

    # Relative processors
    def processorrelativex(self,o,relx):
        return o.x - relx

    def processorrelativey(self,o,rely):
        return o.y - rely

    def collisionlistrelativeonmouse(self,list,relx,rely):
        for i in range(0,list.length):### NOTE1 -1
            o = None
            o = list.getwithindex(i)###list.getlistobject(o)

            if o:
            
                x = o.x
                y = o.y
                mx = self.processorrelativex(self.mouse,relx)
                my = self.processorrelativey(self.mouse,rely)

                if o and mx >= x and mx <= x + o.w and my >= y and my <= y + o.h:   	
                    return o
        return None



    def update(self):
        "move the fist based on the mouse position"
        
#        pos = pygame.mouse.get_pos()
#        self.rect.midtop = pos
#        if self.punching:
#            self.rect.move_ip(5, 10)
    

if __name__ == "__main__":
   foo = Game()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemghoststory import *
from entityfactory import *
from food import *

class Ghoststory(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemghoststory())
        self.addimage('ghoststory1-80x120.bmp',0,0,0)
        self.addimage('ghoststory1-80x120.bmp',0,0,0)
        self.addimage('ghoststory1-80x120.bmp',0,0,0)
        self.addimage('ghoststory1-80x120.bmp',0,0,0)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getghoststoryname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
        screen.scr.blit(self.images[0], (self.x, self.y))
        
    def update(self, room):
	1
#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the Ghost Story."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemgoblinguardian import *
from entityfactory import *
from food import *

class Goblinguardian(Enemytalking):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemgoblinguardian())
        self.addimage('goblin1.bmp',0,0,0)
        self.addimage('goblin1.bmp',0,0,0)
        self.addimage('goblin1.bmp',0,0,0)
        self.addimage('goblin1.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin5.bmp',0,0,0)
        self.addimage('goblin5.bmp',0,0,0)
        self.addimage('goblin5.bmp',0,0,0)
        self.addimage('goblin5.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin4.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin3.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)
        self.addimage('goblin2.bmp',0,0,0)

	self.images2 = []
        self.addimage2('goblinleft1.bmp',0,0,0)
        self.addimage2('goblinleft1.bmp',0,0,0)
        self.addimage2('goblinleft1.bmp',0,0,0)
        self.addimage2('goblinleft1.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft5.bmp',0,0,0)
        self.addimage2('goblinleft5.bmp',0,0,0)
        self.addimage2('goblinleft5.bmp',0,0,0)
        self.addimage2('goblinleft5.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft4.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft3.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)
        self.addimage2('goblinleft2.bmp',0,0,0)

        self.counter = 0

	self.direction = "right"
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getgoblinguardianname()

#### NEW FUNCTION
    def addimage2(self,filename,r,g,b):# rgb transparency values
### NOTE same number of images already        self.maximages2 += 1

        image2 = pygame.image.load(filename).convert()
        image2.set_colorkey((r,g,b))
        self.images2.append(image2)

    def collisionboxesnew(self,room):
        o = self.collisionlist(room.boxes)
        if o:
            #self.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):
	if self.entangled:
		return
	if self.collisionboxesnew(room):### JUMP
		if self.direction == "left":
			self.x += 3 
			self.direction = "right"
		elif self.direction == "right":
			self.x -= 3
			self.direction = "left"

	if self.direction == "left":
		self.x -= 1
	elif self.direction == "right":
		self.x += 1

####### other methods
    def drawonmap(self, screen, maproom):
        self.imagescounter += 1
        if self.imagescounter == self.maximages:
            self.imagescounter = 0    
	if self.direction == "right": 
        	screen.scr.blit(self.images[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))
	elif self.direction == "left": 
        	screen.scr.blit(self.images2[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))

    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The goblinguardian drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the knight."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def bounceback(self):
        if self.direction == "up":#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == "down":#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == "left":#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == "right":#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	#r = randint(1,4)
	#self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphangel(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getangel1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getangel2())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphassassin(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getassassin1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getassassin2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphassassinqueen(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getassassinqueen1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getassassinqueen2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphbirdsparrow(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getbirdsparrow1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getbirdsparrow2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphblimp(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getblimp1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getblimp2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphcandleflame1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getcandleflame11())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getcandleflame12())
            self.graph.next.next.next = Graphnode(text.getcandleflame13())
            self.graph.next.next.next.next = Graphnode(text.getcandleflame14())
            self.graph.next.next.next.next.next = Graphnode(text.getcandleflame15())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphcandleflame2(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getcandleflame21())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getcandleflame22())
            self.graph.next.next.next = Graphnode(text.getcandleflame23())
            self.graph.next.next.next.next = Graphnode(text.getcandleflame24())
            self.graph.next.next.next.next.next = Graphnode(text.getcandleflame25())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphchaosknight1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getchaosknight11())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getchaosknight12())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphcherubstatue1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getcherubstatue11())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getcherubstatue12())
            self.graph.next.next.next = Graphnode(text.getcherubstatue13())
            self.graph.next.next.next.next = Graphnode(text.getcherubstatue14())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphdemon1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getdemon11())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getdemon12())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphdjinnofnootie(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getdjinnofnootie1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getdjinnofnootie2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphearthweird(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getearthweird1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getearthweird2())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphghoststory(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getghoststory1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getghoststory2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphgoblinguardian(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getgoblinguardian1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getgoblinguardian2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphhermit(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.gethermit1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.gethermit2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphhobgoblinswordsman1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.gethobgoblinswordsman1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.gethobgoblinswordsman2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphhoundarchon(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.gethoundarchon1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.gethoundarchon2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphknightgrey(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getknightgrey1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getknightgrey2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphkoboldmage(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getkoboldmage1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getkoboldmage2())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphmyconid(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getmyconid1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getmyconid2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphnutter2(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getnutter21())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getnutter22())
#            self.graph.next.next.next = Graphnode(text.getnutter23())
#            self.graph.next.next.next.next = Graphnode(text.getnutter24())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphnutter3(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getnutter31())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getnutter32())
            self.graph.next.next.next = Graphnode(text.getnutter33())
            self.graph.next.next.next.next = Graphnode(text.getnutter34())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphnutter4(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getnutter41())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getnutter42())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphnutternootie(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getnutternootie1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getnutternootie2())
            self.graph.next.next.next = Graphnode(text.getnutternootie3())
            self.graph.next.next.next.next = Graphnode(text.getnutternootie4())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphnutter(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getnutter1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getnutter2())
            self.graph.next.next.next = Graphnode(text.getnutter3())
            self.graph.next.next.next.next = Graphnode(text.getnutter4())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphorcblue1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getorcblue11())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getorcblue12())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphorcguardian(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getorcguardian1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getorcguardian2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphorcpaladin(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getorcpaladin1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getorcpaladin2())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphorcswordsmanblue(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getorcswordsmanblue1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getorcswordsmanblue2())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphorcvillagewarrior1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getorcvillagewarrior11())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getorcvillagewarrior12())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Graphnode(object):
    def __init__(self, o):#pass
        self.node = o
        self.next = None

class Graph(Graphnode):
    def __init__(self,o):
        Graphnode.__init__(self,"dummy")
        self.next = Graphnode(o)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphshieldmaiden(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getshieldmaiden1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getshieldmaiden2())
            self.graph.next.next.next = Graphnode(text.getshieldmaiden3())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphtrollblack(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.gettrollblack1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.gettrollblack2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphvillageorc1(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getvillageorc11())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getvillageorc12())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphvillageorc2(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getvillageorc21())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getvillageorc22())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from graph import *

class Graphvillageorc3(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getvillageorc31())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getvillageorc32())
#            self.graph.next.next.next = Graphnode(text.getearthweird3())
        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphwaterdevilfemale(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getwaterdevilfemale1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getwaterdevilfemale2())
            self.graph.next.next.next = Graphnode(text.getwaterdevilfemale3())
            self.graph.next.next.next.next = Graphnode(text.getwaterdevilfemale4())
            self.graph.next.next.next.next.next = Graphnode(text.getwaterdevilfemale5())
            self.graph.next.next.next.next.next.next = Graphnode(text.getwaterdevilfemale6())
            self.graph.next.next.next.next.next.next.next = Graphnode(text.getwaterdevilfemale7())
            self.graph.next.next.next.next.next.next.next.next = Graphnode(text.getwaterdevilfemale8())
            self.graph.next.next.next.next.next.next.next.next.next = Graphnode(text.getwaterdevilfemale9())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from graph import *

class Graphwaterdevil(object):
    def __init__(self):
        self.graph = None
        self.currentnode = None

    def get(self,text):

        if not self.graph or not self.currentnode:#runtime load of textgraph
            self.graph = Graph(text.getwaterdevil1())
            self.currentnode = self.graph
            self.graph.next.next = Graphnode(text.getwaterdevil2())

        if self.currentnode.next:# dummy start of queue in graph.py
            self.currentnode = self.currentnode.next
            return self.currentnode.node
        else:
            self.currentnode = self.graph
        return None
            

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemhermit import *
from entityfactory import *
from food import *

class Hermit(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemhermit())
        self.addimage('hermit1.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.gethermitname()

#    def gettalk(self):
#        talksystem.gettalk(self)
    def update(self,room):
	1

####### other methods
    def draw(self,screen):
        screen.scr.blit(self.images[0], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the hermit."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemhobgoblinswordsman1 import *

class Hobgoblinswordsman1(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemhobgoblinswordsman1())
        self.addimage('hobgoblinswordsman11.bmp',255,255,255)
        self.addimage('hobgoblinswordsman2.bmp',255,255,255)
        self.addimage('hobgoblinswordsman11.bmp',255,255,255)
        self.addimage('hobgoblinswordsman3.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.gethobgoblinswordsmanname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the hobgoblin sowrdsman."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemhobgoblinswordsman1 import *

class Hobgoblinswordsmanchief1(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemhobgoblinswordsman1())
        self.addimage('hobgoblinchief1.bmp',255,255,255)
        self.addimage('hobgoblinchief1.bmp',255,255,255)
        self.addimage('hobgoblinchief1.bmp',255,255,255)
        self.addimage('hobgoblinchief1.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.gethobgoblinswordsmanname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the hobgoblin sowrdsman."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010
# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemangel import *

class Houndarchon(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemangel())
        self.addimage('houndarchon1.bmp',255,255,255)
        self.addimage('houndarchon2.bmp',255,255,255)
        self.addimage('houndarchon3.bmp',255,255,255)
        self.addimage('houndarchon4.bmp',255,255,255)
        self.addimage('houndarchon3.bmp',255,255,255)
        self.addimage('houndarchon2.bmp',255,255,255)
        ###self.addimage('houndarchon1.bmp',255,255,255)
        ###self.addimage('houndarchon2.bmp',255,255,255)
        ###self.addimage('houndarchon3.bmp',255,255,255)
        ###self.addimage('houndarchon3.bmp',255,255,255)
        ###self.addimage('houndarchon2.bmp',255,255,255)
        self.counter = 0

	self.usedspellbookdracolich = 0

####### TEXT / FONT interface
    def getname(self,text):
        return text.gethoundarchonname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):

        self.counter += 1

        if self.counter >= 50:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the houndarchon."
            return 1
        else:
            return None

    def usedracolichspellbook(self,game):
        string = "You have destroyed the dracolich's spellbook"
        string += "\n"
        print "BAZ"

	s = ""

        f = open("./workfile",'r')
        for line in f:
            s += line
                
        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

	self.usedspellbookdracolich = 1



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorybomb(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "bomb1.bmp")

    def getname():
	return "Bombs"	

    def use(self,e,game):
        print 'You used a bomb on %s' % e
        if e:
            return e.usebomb(game)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorychest1(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "chest1contents.bmp")

    def use(self,e,game):
        print 'You used a chest 1 on %s' % e
        if e:
            return e.usechest1(game)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorychestmanapotion(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "chestmanapotioncontents.bmp")

    def use(self,e,game):
        print 'You used a mana potion chest on %s' % e
        if e:
            return e.usechestmanapotion(game)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *


class Inventoryitem(object):
    def __init__(self,imagefilename):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((0,0,0))#FIXME rgb transdparency

    def draw(self,screen,x,y):
        screen.scr.blit(self.image, (x, y))

    def addtolist(self,list):
        list.addobject(self)

### NOTE There s no fallthrough for item usage


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventorykey(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "key1.bmp")

    def use(self,e,game):
        print 'You used a key on %s' % e
	if e:
		return e.usekey(game)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from list import *
from inventorybomb import *

class Inventory(object):
    def __init__(self):
        self.background = pygame.image.load('bg_inventory.bmp').convert()
        self.list = List()
        self.list.addobject(Inventorybomb())

        self.rectimage = pygame.image.load('rect1.bmp').convert()
        self.rectimage.set_colorkey((0,0,0))
        self.selectioncounter = 0 

    def draw(self,screen):

        screen.scr.blit(self.background, (0, 0))

        position = pygame.mouse.get_pos()
        x = position[0]
        y = position[1]
        self.drawrect(screen,x-40,y-40)

        for i in range(0,self.list.length):
            o = self.list.getwithindex(i)
# pass by value FIXME
#             o = None
#             o = self.list.getlistobject(o)
            if o:
                o.draw(screen,80*i,0)



    def drawrect(self,screen,x,y):
        screen.scr.blit(self.rectimage, (x, y))


    def moveleft(self):
        if self.selectioncounter > 0:
            self.selectioncounter -= 1

    def moveright(self):
        if self.selectioncounter < 9:
            self.selectioncounter += 1

    def getitem(self,o):
	#        for i in range(0,self.selectioncounter):
	#            o = None
	#            o = self.list.getlistobject(o)
        o = self.list.getwithindex(self.selectioncounter) 
        if o:
            return o

        return None

    def getinventoryitemwithmouse(self,o,mouse):
        position = pygame.mouse.get_pos()
        x = position[0]
        y = position[1]
	print "x=%d" % x
	print "y=%d" % y
	i = 1 
	previ = 0
	for i in range(1,9):
	    ###print "80i=%d" % i*80
	    if x <= 80*i and x >= 80*previ:
                o = self.list.getwithindex(i-1) 
                if o:
                    return o
	    previ = i
        return None

    def additem(self,o):
        self.list.addobject(o)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventoryringyellow(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "ringblue1.bmp")

    def use(self,e,game):
        print 'You used a blue ring on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventoryringyellow(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "ringyellow1.bmp")

    def use(self,e,game):
        print 'You used a yellow ring on %s' % e
        if e:
            e.useyellowring(game)
	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventoryscrollinvisibility(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "scroll1.bmp")

    def use(self,e,game):
        print 'You used a scroll of invisibility on %s' % e
        if e:
            e.usescrollinvisibility(game)
	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *

from inventoryitem import *

class Inventoryseraphimsword(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "sword1blue.bmp")

    def use(self,e,game):
        print 'You used a seraphimsword on %s' % e

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from random import *
from inventoryitem import *

class Inventoryspellbookdracolich(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "spellbookdracolich1.bmp")

    # Use item on player or entity
    def use(self,e,game):
        print 'You used a dracolich spellbook on %s' % e
        if e:
            e.usedracolichspellbook(game)
    
    def getname():
        return "Dracolich's spellbook"
           

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from random import *
from inventoryitem import *

class Inventoryspellbooknootie(Inventoryitem):
    def __init__(self):
        Inventoryitem.__init__(self, "spellbooknootie1.bmp")

    # Use item on player or entity
    def use(self,e,game):
        print 'You used Nootie\'s spellbook on %s' % e
        if e:
            e.usenootiespellbook(game)
           

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Key2(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('key2blue.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ key registered"
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getkey2name()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Key3(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('key3.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ key3 registered"
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getkey3name()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Key(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('key1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber
	###self.flag = 0

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

	###if self.flag:
	###	return None

        if Utilities().readandfindstring(string):
            print "+++ key registered"
	    ###self.flag = 1
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getkeyname()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemmyconid import *
from entityfactory import *
from food import *

class Knightdark(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemmyconid())
        self.addimage('knightdark1.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getknightdarkname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
            screen.scr.blit(self.images[0], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The dark knight drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the dark knight."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#from bouncer import *
from enemytalking import *
from talksystemknightgrey import *
from entityfactory import *
from food import *

class Knightgrey(Enemytalking):#Bouncer):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemknightgrey())
        self.addimage('knightgrey1.bmp',255,255,255)
        self.addimage('knightgrey2.bmp',255,255,255)
        self.addimage('knightgrey3.bmp',255,255,255)
        self.addimage('knightgrey4.bmp',255,255,255)
        self.counter = 0

	self.direction = 1 
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getknightgreyname()

#    def gettalk(self):
#        talksystem.gettalk(self)
#    def update(self,room):
#	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The knightgrey drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the knightgrey."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room

	if self.entangled:
		return

	ri = randint(0,42)
	if ri == 14:
	    r = randint(1,4)
	    self.direction = r
	o = None
	o = self.collisionboxes()

	if o:
	    r = randint(0,40)
	    if r < 2:
	        self.bounceback(None) 	
        if self.direction == 1:#north
	     self.y -= 1
        elif self.direction == 3:#south
 	     self.y += 1
        elif self.direction == 4:#west
             self.x -= 1
        elif self.direction == 2:#east
	     self.x += 1


    def bounceback(self,level):
        if self.direction == 1:#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == 3:#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == 4:#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == 2:#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	r = randint(1,4)
	self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from entity import *
import random
from utility import *
from talksystemkoboldmage import *

class Koboldmage(Enemytalking):#FIXME emytalking):
    "Kobold mage"
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemkoboldmage())

        self.addimage('koboldwizard1.bmp',0,0,0)
        self.addimage('koboldwizardcast1.bmp',0,0,0)
        
#        self.counter = 0
        self.direction = "south"
        self.hitpoints = 1

        self.casting = None
        self.castingcounter = 0

        self.dungeonnumber = "1"#dungeonnumber
        self.keynumber = "1"#keynumber


    def draw(self,screen):

        r3 = randint(0,450)
        if r3 < 1:
            self.casting = 1

        if self.casting:
            if self.castingcounter < 10:
                self.castingcounter += 1
                screen.scr.blit(self.images[1], (self.x, self.y))
                return
        else:
            screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):

        if self.casting:
            if self.castingcounter >= 10:
                self.casting = None
                self.castingcounter = 0
                #FIXME1 relative x y
                level.summonskeleton(self.x-50,self.y+50)
            


        r = randint(0,100)

        if r < 1:
            r2 = randint(0,3)
            if r2 == 0:
                self.direction = "north"
            if r2 == 1:
                self.direction = "south"
            if r2 == 2:
                self.direction = "west"
            if r2 == 3:
                self.direction = "east"

        #FIXME high load collision checks
        if self.collisionlist(self,level.entities) != self or self.collisionlist(self,level.exits) or self.collisionlist(self,level.boxes):#FIXME != self
            print "entity bounce back"
            self.bounceback()
            return

        if self.direction == "north":
            self.y -= 1
        if self.direction == "south":
            self.y += 1
        if self.direction == "west":
            self.x -= 1
        if self.direction == "east":
            self.x += 1
        
            

    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()

    def remove(self,list):
#        string = "You have killed boss 1 - dungeon 2\n"




        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

            
        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None


        if self.hitpoints == 0:

            f = open("./workfile",'r')
            for line in f:
                s += line
                
            f = open("./workfile",'w')
            
            f.write(s)
            f.write(string)
            f.write("\n")

            list.remove(self)

            return 1

    def hit(self):
        self.hitpoints -= self.decreasehp


    def readkoboldmage(self,list):
        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ kobold mage already neutralised"
#            self.removeallenemies()
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getkoboldmagename()
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from roommanager import *

class Level:
    "Level"
    def __init__(self, screen):
        self.screen = screen
        self.roommanager = Roommanager(screen)

        self.gameover = 0

    def update(self,entity):
       # img = pygame.image.load('rect1.bmp').convert()
       # rect.set_colorkey((0,0,0))
       # rect  = pygame.draw.rect(self.screen, 0x0ff0000)
       # bg = pygame.image.load('bg0.bmp').convert()
       # self.screen.scr.blit(bg, (0, 0))
       # screen.draw(self.entities)
       # pygame.display.update()
	1

    def draw(self,entity):
        1
        
    def setgameover(self):
	print ("game over")
        self.gameover = 1
        1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class List:
    def __init__(self):
        self.list = []
        self.length = 0
        self.index = 0

    def add(self,o):
        o.addtolist(self)

    def addobject(self,o):
        self.length += 1
        self.list.append(o)
    
    def remove(self,o):
        resultlist = []
        self.length = 0
        
        for el in self.list:
            if  el != o:
                resultlist.append(el)
                self.length += 1
        self.list = resultlist
                

    def getlistobject(self,o):#NOTE1 o not list
        if self.index < self.length:
            o = self.list[self.index]
            self.index += 1
            return o
        else:
            self.index = 0
        return None

    def getwithindex(self,index):
        if index < self.length:
            return self.list[index]

        return None

#    def resetindex(self,idx):
#        self.index = idx
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *

class Lockeddooreast2(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('lockeddooreast2.bmp',255,255,255)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,level):
        1

    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string = "\n"
        print "destroy"

        if Utilities().readandfindstring(string):
#            print "foo"
            list.remove(self)
            return 1
        
        return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *
class Lockeddooreast(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('lockeddooreast1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,level):
        1

    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string = "\n"
        print "destroy"

        if Utilities().readandfindstring(string):
#            print "foo"
            list.remove(self)
            return 1
        
        return None
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *
class Lockeddoorgreywalleast(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('lockeddoorgreywalleast1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,level):
        1

    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string = "\n"
        print "destroy"

        if Utilities().readandfindstring(string):
#            print "foo"
            list.remove(self)
            return 1
        
        return None
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *

class Lockeddoornorth2(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('lockeddoornorth2.bmp',255,255,255)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,level):
        1

    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string = "\n"
        print "destroy"

        if Utilities().readandfindstring(string):
#            print "foo"
            list.remove(self)
            return 1
        
        return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *

class Lockeddoornorth(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('lockeddoornorth1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,level):
        1

    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string = "\n"
        print "destroy"

        if Utilities().readandfindstring(string):
#            print "foo"
            list.remove(self)
            return 1
        
        return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *

class Lockeddoorsouth(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('lockeddoorsouth1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,level):
        1

    def remove(self,list):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string = "\n"
        print "destroy"

        if Utilities().readandfindstring(string):
#            print "foo"
            list.remove(self)
            return 1
        
        return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *
class Lockeddoorwest(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('lockeddoorwest1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,level):
        1

    def destroy(self):
        string = "You have a key "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber

        print "destroy"

        if Utilities().readandfindstring("You have a key 1 - dungeon 1") == 1:
#            print "foo"
            return 1
        else:
            return 0
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from bomb import *
from list import *

class Maproomchbg(Maproom):
    "Room with a (big) map , changing backgrounds"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.relativex = x
        self.relativey = y
	self.counter = 0
	self.background = List()

    def draw(self,screen):
	self.counter += 1
	if self.counter < 10:
            screen.scr.blit(self.background.getwithindex(0), (0+self.relativex, 0+self.relativey))
	elif self.counter < 20:
            screen.scr.blit(self.background.getwithindex(1), (0+self.relativex, 0+self.relativey))
	elif self.counter < 30:
            screen.scr.blit(self.background.getwithindex(2), (0+self.relativex, 0+self.relativey))
	else:
	    self.counter = 0
        screen.drawonmap(self)

    def update(self,player,level,swordplay):
        self.updatelist(self.entities)

        o = player.collisionlistrelative(self.entities,self.relativex,self.relativey)
        if o:
	    if swordplay != 0:
		print("+++++++++++++++SWORDPLAY")
		o.hitpoints -= 1
        	if o.hitpoints <= 0:
            	    self.entities.remove(o)    
	    else:
	        o.dofood(player) 
	    	o.doplatform(player,level)
               	player.bounceback(level)
                o.decreasehpinplayer(player,level)
            	o.remove(self.entities)
     
 
    def moveup(self,player):
        player.direction = "north"
        self.relativey = self.relativey + 10

    def movedown(self,player):
        player.direction = "south"
        self.relativey = self.relativey - 10

    def moveleft(self,player):
        player.direction = "west"
        self.relativex = self.relativex + 10

    def moveright(self,player):
        player.direction = "east"
        self.relativex = self.relativex - 10


    #### COLLISION CODE - OVERRIDING ROOM CODE 


    def processorrelativex(self,o):
        return o.x - self.relativex

    def processorrelativey(self,o):
        return o.y - self.relativey

    def collisionlistbombrelative(self,bomb,list):
        for o in list.list:
            if o:
                x = self.processorrelativex(o)
                y = self.processorrelativey(o)
                if x >= bomb.x - bomb.w and x <= bomb.x + bomb.w and y >= bomb.y - bomb.h and y <= bomb.y + bomb.h:
                    return o
        return None

#     def warp(self,x,y):
#         self.relativex = 800
#         self.relativey = 800


    def collisionexits(self,player,roommanager):
        o = player.collisionlistrelative(self.exits, self.relativex, self.relativey)

        if o:
            print 'exit foo x=%d,y=%d px=%d py=%d' % (o.x,o.y,player.x,player.y)
            o.room.loadroom()
            roommanager.room = o.room
            player.warp(o.newx,o.newy)
            return 1
        return None

    def collisionboxes(self,player):
        o = player.collisionlistrelative(self.boxes, self.relativex, self.relativey)
        if o:
            #player.bounceback()
            return 1
        return None


    def collisionandremoveenemieswithbomb(self, bomb):

        b = Bomb(self.processorrelativex(bomb),self.processorrelativey(bomb),80,80)
#        bomb.x = self.processorrelativex(bomb.x)
#        bomb.y = self.processorrelativey(bomb.y)
        o = self.collisionlistbombrelative(b,self.entities)
        if o:
            o.hit()
            o.remove(self.entities)
            self.entities.remove(o)
            
#     def summonskeletonunderplayercommand(self,x,y):
#         self.addenemy(Skeletonunderplayercommand(x,y,50,50))


    def summonskeleton(self,x,y):
        self.addenemy(Skeleton2(x-self.relativex,y-self.relativey,50,50))


    # Dropping bomb entities
    def addsprite(self,sprite):
        sprite.x -= self.relativex
        sprite.y -= self.relativey
        self.addentity(sprite)


    def collisionplayerrelative(self,mouse,player,relx,rely):
        mouse.collisionplayerrelative(player,relx,rely)

    def domouse(self,game):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)#game.collisionplayerrelative(self)
        if p:
            foo = game.leftbuttonpressed(game.player)
            if foo:
                return
            
        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o:
            foo = game.mouse.leftbuttonpressed(o,game)
#            print foo
            if foo:
                game.screen.scr.blit(game.font.render(foo, 16, (255,255,255)), (10,10))
#                print foo
            else:
                game.screen.scr.blit(game.font.render(o.getname(game.text), 10, (0,0,0)), (game.mouse.x+10,game.mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)
            
                
    def domouseinventory(self,game):#,screen,mouse,font,text,item,player):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)
        if p:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(game.player,game)
            if foo:
                return 1

        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o and game.inventoryitem:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(o,game)#.text,game.inventoryitem)
            if foo:
                return 1

        if not o and game.mouse.press(0):
            return 1

        return None


    #def addimage(self,filename,r,g,b):# rgb transparency values
    #    self.maximages += 1

    #    image = pygame.image.load(filename).convert()
    #    image.set_colorkey((r,g,b))
    #    self.background.append(image)


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from room import *
from bomb import *
from maproom import *

class Maproomleftright(Maproom):
    "Room with a (big) map only movable left and right"
    def __init__(self,x,y):
        Room.__init__(self)
        self.relativex = x
        self.relativey = y

    def draw(self,screen):
        screen.scr.blit(self.background, (0+self.relativex, 0+self.relativey))
        screen.drawonmap(self)

    def update(self,player,level,swordplay):
        self.updatelist(self.entities)

        o = player.collisionlistrelative(self.entities,self.relativex,self.relativey)
        if o:
	    if swordplay != 0:
		print("+++++++++++++++SWORDPLAY")
		o.hitpoints -= 1
        	if o.hitpoints <= 0:
            	    self.entities.remove(o)    
	    else:
	        o.dofood(player) 
	    	o.doplatform(player,level)
               	player.bounceback(level)
                o.decreasehpinplayer(player,level)
            	o.remove(self.entities)
     
 
    def moveup(self,player):
        player.direction = "north"
        #self.relativey = self.relativey + 10
	player.y -= 10

    def movedown(self,player):
        player.direction = "south"
        #self.relativey = self.relativey - 10
	player.y += 10

    def moveleft(self,player):
        player.direction = "west"
        self.relativex = self.relativex + 10

    def moveright(self,player):
        player.direction = "east"
        self.relativex = self.relativex - 10
	print ("x=%d y=%d" % (self.relativex, player.y))

    #### COLLISION CODE - OVERRIDING ROOM CODE 


    def processorrelativex(self,o):
        return o.x - self.relativex

#    def processorrelativey(self,o):
#        return o.y - self.relativey

    def collisionlistbombrelative(self,bomb,list):
        for o in list.list:
            if o:
                x = self.processorrelativex(o)
                y = self.processorrelativey(o)
                if x >= bomb.x - bomb.w and x <= bomb.x + bomb.w and y >= bomb.y - bomb.h and y <= bomb.y + bomb.h:
                    return o
        return None

#     def warp(self,x,y):
#         self.relativex = 800
#         self.relativey = 800


    def collisionexits(self,player,roommanager):
        o = player.collisionlistrelative(self.exits, self.relativex, self.relativey)

        if o:
            print 'exit foo x=%d,y=%d px=%d py=%d' % (o.x,o.y,player.x,player.y)
            o.room.loadroom()
            roommanager.room = o.room
            player.warp(o.newx,o.newy)
            return 1
        return None

    def collisionboxes(self,player):
        o = player.collisionlistrelative(self.boxes, self.relativex, self.relativey)
        if o:
            #player.bounceback()
            return 1
        return None


    def collisionandremoveenemieswithbomb(self, bomb):

        b = Bomb(self.processorrelativex(bomb),self.processorrelativey(bomb),80,80)
#        bomb.x = self.processorrelativex(bomb.x)
#        bomb.y = self.processorrelativey(bomb.y)
        o = self.collisionlistbombrelative(b,self.entities)
        if o:
            o.hit()
            o.remove(self.entities)
            self.entities.remove(o)
            
#     def summonskeletonunderplayercommand(self,x,y):
#         self.addenemy(Skeletonunderplayercommand(x,y,50,50))


    def summonskeleton(self,x,y):
        self.addenemy(Skeleton2(x-self.relativex,y-self.relativey,50,50))


    # Dropping bomb entities
    def addsprite(self,sprite):
        sprite.x -= self.relativex
        sprite.y -= self.relativey
        self.addentity(sprite)


    def collisionplayerrelative(self,mouse,player,relx,rely):
        mouse.collisionplayerrelative(player,relx,rely)

    def domouse(self,game):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)#game.collisionplayerrelative(self)
        if p:
            foo = game.leftbuttonpressed(game.player)
            if foo:
                return
            
        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o:
            foo = game.mouse.leftbuttonpressed(o,game)
#            print foo
            if foo:
                game.screen.scr.blit(game.font.render(foo, 16, (255,255,255)), (10,10))
#                print foo
            else:
                game.screen.scr.blit(game.font.render(o.getname(game.text), 10, (0,0,0)), (game.mouse.x+10,game.mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)
            
                
    def domouseinventory(self,game):#,screen,mouse,font,text,item,player):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)
        if p:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(game.player,game)
            if foo:
                return 1

        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o and game.inventoryitem:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(o,game)#.text,game.inventoryitem)
            if foo:
                return 1

        if not o and game.mouse.press(0):
            return 1

        return None


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from room import *
from bomb import *

class Maproom(Room):
    "Room with a (big) map"
    def __init__(self,x,y):
        Room.__init__(self)
        self.relativex = x
        self.relativey = y

    def draw(self,screen):
        screen.scr.blit(self.background, (0+self.relativex, 0+self.relativey))
        screen.drawonmap(self)

    def update(self,player,level,swordplay):
        self.updatelist(self.entities)

        o = player.collisionlistrelative(self.entities,self.relativex,self.relativey)
        if o:
	    if swordplay != 0:
		print("+++++++++++++++SWORDPLAY")
		o.hit()#points -= 1
        	if o.hitpoints <= 0:
            	    self.entities.remove(o)    
	    else:
	        o.dofood(player)
	    	o.doplatform(player,level)
               	player.bounceback(level)
                o.decreasehpinplayer(player,level)
            	o.remove(self.entities)
     
 
    def moveup(self,player):
        player.direction = "north"
        self.relativey = self.relativey + 10

    def movedown(self,player):
        player.direction = "south"
        self.relativey = self.relativey - 10

    def moveleft(self,player):
        player.direction = "west"
        self.relativex = self.relativex + 10

    def moveright(self,player):
        player.direction = "east"
        self.relativex = self.relativex - 10


    #### COLLISION CODE - OVERRIDING ROOM CODE 


    def processorrelativex(self,o):
        return o.x - self.relativex

    def processorrelativey(self,o):
        return o.y - self.relativey

    def collisionlistbombrelative(self,bomb,list):
        for o in list.list:
            if o:
                x = self.processorrelativex(o)
                y = self.processorrelativey(o)
                if x + 12>= bomb.x - bomb.w and x <= bomb.x + bomb.w +12 and y+12 >= bomb.y - bomb.h and y <= bomb.y + bomb.h +12:
                    return o
        return None

#     def warp(self,x,y):
#         self.relativex = 800
#         self.relativey = 800


    def collisionexits(self,player,roommanager):
        o = player.collisionlistrelative(self.exits, self.relativex, self.relativey)

        if o:
            print 'exit foo x=%d,y=%d px=%d py=%d' % (o.x,o.y,player.x,player.y)
            o.room.loadroom()
            roommanager.room = o.room
            player.warp(o.newx,o.newy)
            return 1
        return None

    def collisionboxes(self,player):
        o = player.collisionlistrelative(self.boxes, self.relativex, self.relativey)
        if o:
            #player.bounceback()
            return 1
        return None


    def collisionandremoveenemieswithbomb(self, bomb):

        b = Bomb(self.processorrelativex(bomb),self.processorrelativey(bomb),80,80)
#        bomb.x = self.processorrelativex(bomb.x)
#        bomb.y = self.processorrelativey(bomb.y)
        o = self.collisionlistbombrelative(b,self.entities)
        if o:
            o.hit()
            o.remove(self.entities)
            self.entities.remove(o)
            
    def summonskeletonunderplayercommand(self,x,y):
        self.addenemy(Skeletonunderplayercommand(x,y,50,50))


    def summonskeleton(self,x,y):
        self.addenemy(Skeleton2(x-self.relativex,y-self.relativey,50,50))


    # Dropping bomb entities
    def addsprite(self,sprite):
        sprite.x -= self.relativex
        sprite.y -= self.relativey
        self.addentity(sprite)


    def collisionplayerrelative(self,mouse,player,relx,rely):
        return mouse.collisionplayerrelative(player,relx,rely)

    def domouse(self,game):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)#game.collisionplayerrelative(self)
        if p:
            print ("mouse click on player 1")
            foo = game.leftbuttonpressed(game.player)
            if foo:
		print ("mouse click on player 12")
                return
            
        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o:
            foo = game.mouse.leftbuttonpressed(o,game)
#            print foo
            if foo:
		### BLIT RETURN TALK TEXT
                game.screen.scr.blit(game.font.render(foo, 16, (255,255,255)), (20,330))
#                print foo
            else:
                game.screen.scr.blit(game.font.render(o.getname(game.text), 10, (0,0,0)), (game.mouse.x+10,game.mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)
            
                
    def domouseinventory(self,game):#,screen,mouse,font,text,item,player):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)
        if p:
            footext4 = game.mouse.leftbuttonpressedwithinventoryitem(game.player,game)
            if footext4 and footext4 != "":
                return footext4 

        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o and game.inventoryitem:
            footext5 = game.mouse.leftbuttonpressedwithinventoryitem(o,game)#.text,game.inventoryitem)
            if footext5 and footext5 != "":
                return footext5 

        if not o and game.mouse.press(0):
            return 1

        return None


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from maproom import *
from bomb import *

class Maproomupdown(Maproom):
    "Room with a (big) map, only scrollable up down"
    def __init__(self,x,y):
        Maproom.__init__(self,x,y)
        self.relativex = x
        self.relativey = y

    def draw(self,screen):
        screen.scr.blit(self.background, (0+self.relativex, 0+self.relativey))
        screen.drawonmap(self)

    def update(self,player,level,swordplay):
        self.updatelist(self.entities)

        o = player.collisionlistrelative(self.entities,self.relativex,self.relativey)
        if o:
	    if swordplay != 0:
		print("+++++++++++++++SWORDPLAY")
		o.hitpoints -= 1
        	if o.hitpoints <= 0:
            	    self.entities.remove(o)    
	    else:
	        o.dofood(player) 
	    	o.doplatform(player,level)
               	player.bounceback(level)
                o.decreasehpinplayer(player,level)
            	o.remove(self.entities)
     
 
    def moveup(self,player):
        player.direction = "north"
        self.relativey = self.relativey + 10
	print ("x=%d y=%d" % (player.x,self.relativey))	

    def movedown(self,player):
        player.direction = "south"
        self.relativey = self.relativey - 10
	print ("x=%d y=%d" % (player.x,self.relativey))	

    def moveleft(self,player):
        player.direction = "west"
        #self.relativex = self.relativex + 10
	player.x -= 10
	print ("x=%d y=%d" % (player.x,self.relativey))	
	
    def moveright(self,player):
        player.direction = "east"
        #self.relativex = self.relativex - 10
	player.x += 10
	print ("x=%d y=%d" % (player.x,self.relativey))	


    #### COLLISION CODE - OVERRIDING ROOM CODE 


    def processorrelativex(self,o):
        return o.x - self.relativex

    def processorrelativey(self,o):
        return o.y - self.relativey

    def collisionlistbombrelative(self,bomb,list):
        for o in list.list:
            if o:
                x = self.processorrelativex(o)
                y = self.processorrelativey(o)
                if x >= bomb.x - bomb.w and x <= bomb.x + bomb.w and y >= bomb.y - bomb.h and y <= bomb.y + bomb.h:
                    return o
        return None

#     def warp(self,x,y):
#         self.relativex = 800
#         self.relativey = 800


    def collisionexits(self,player,roommanager):
        o = player.collisionlistrelative(self.exits, self.relativex, self.relativey)

        if o:
            print 'exit foo x=%d,y=%d px=%d py=%d' % (o.x,o.y,player.x,player.y)
            o.room.loadroom()
            roommanager.room = o.room
            player.warp(o.newx,o.newy)
            return 1
        return None

    def collisionboxes(self,player):
        o = player.collisionlistrelative(self.boxes, self.relativex, self.relativey)
        if o:
            #player.bounceback()
            return 1
        return None


    def collisionandremoveenemieswithbomb(self, bomb):

        b = Bomb(self.processorrelativex(bomb),self.processorrelativey(bomb),80,80)
#        bomb.x = self.processorrelativex(bomb.x)
#        bomb.y = self.processorrelativey(bomb.y)
        o = self.collisionlistbombrelative(b,self.entities)
        if o:
            o.hit()
            o.remove(self.entities)
            self.entities.remove(o)
            
#     def summonskeletonunderplayercommand(self,x,y):
#         self.addenemy(Skeletonunderplayercommand(x,y,50,50))


    def summonskeleton(self,x,y):
        self.addenemy(Skeleton2(x-self.relativex,y-self.relativey,50,50))


    # Dropping bomb entities
    def addsprite(self,sprite):
        sprite.x -= self.relativex
        sprite.y -= self.relativey
        self.addentity(sprite)


    def collisionplayerrelative(self,mouse,player,relx,rely):
        mouse.collisionplayerrelative(player,relx,rely)

    def domouse(self,game):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)#game.collisionplayerrelative(self)
        if p:
            foo = game.leftbuttonpressed(game.player)
            if foo:
                return
            
        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o:
            foo = game.mouse.leftbuttonpressed(o,game)
#            print foo
            if foo:
                game.screen.scr.blit(game.font.render(foo, 16, (255,255,255)), (10,10))
#                print foo
            else:
                game.screen.scr.blit(game.font.render(o.getname(game.text), 10, (0,0,0)), (game.mouse.x+10,game.mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)
            
                
    def domouseinventory(self,game):#,screen,mouse,font,text,item,player):
        # Collide mouse with player
        p = game.domouseonplayerrelative(self)
        if p:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(game.player,game)
            if foo:
                return 1

        # Collide mouse with entities
        o = None
        o = game.collisionlistrelativeonmouse(self.entities,self.relativex,self.relativey)
        if o and game.inventoryitem:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(o,game)#.text,game.inventoryitem)
            if foo:
                return 1

        if not o and game.mouse.press(0):
            return 1

        return None


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010


# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from tree4 import *
from maproom import *

class Maproom1(Maproom):
    "Example"

    def __init__(self):
        Maproom.__init__(self,-100,-100)
        self.loadwalls()

    def loadwalls(self):
        
        # NORTH WALL
        self.addbox(0,0,640,80)
        # SOUTH WALL
        self.addbox(0,400,640,80)
        # WEST WALL
        self.addbox(0,0,60,480)
        # EAST WALL
        self.addbox(580,0,60,480)


    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):
        factory = Entityfactory()

#         # LAVA 
 #       self.addbox(400,0,240,200)


        self.addenemy(factory.make(Entity.ENTITY_MYCONID,300,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,350,250,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,400,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,450,250,50,50))


#         # EAST EXIT
#         self.addexit(580,0,60,480,102,70,210,Room2dungeon2())
#         # NORTH EXIT
#         self.addexit(0,0,400,80,104,200,390,Room4dungeon2())

        self.background = pygame.image.load('room1dungeon2.bmp').convert()



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Money(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('money1.bmp',255,255,255)

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    def remove(self,list):
	print ("You get some money.\n")
        list.remove(self)
	return None
    
    def getname(self,text):
        return text.getmoneyname()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *


class Mouse(object):
    def __init__(self):
        self.position = None
        self.x = None
        self.y = None
        # for collision code
        self.w = 20
        self.h = 20
        self.update()
#        self.pressed = None
        self.previoustext = None

    def update(self):
        self.position = pygame.mouse.get_pos()
        self.x = self.position[0]
        self.y = self.position[1]

    def draw(self,screen,item):
        if item:
            screen.scr.blit(item.image, (self.x, self.y))

    # FIXME copy-paste entity
#     def collisionlist(self,collider,list):
#         for i in range(0,list.length):
#             o = None
#             o = list.getlistobject(o)
#             if o and collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h:   	
#                 return o
#         return None

#     def collisionlistrelative(self,collider,list,relx,rely):
#         for i in range(0,list.length):
#             o = None
#             o = list.getlistobject(o)

#             if o:
#                 #FIXME2
#                 x = o.x#self.processorrelativex(o,relx)
#                 y = o.y#self.processorrelativey(o,rely)

#                 mx = self.processorrelativex(self,relx)
#                 my = self.processorrelativey(self,rely)

#                 if mx >= x and mx <= x + o.w and my >= y and my <= y + o.h:
#                     return o
#         return None



    def collisionplayer(self,player):
        return player.collisionplayer(self)

    def collisionplayerrelative(self,player,relx,rely):
        return player.collisionplayerrelative(self,relx,rely)

    # generic method
    def press(self,buttonnumber):
        if  pygame.mouse.get_pressed()[buttonnumber]:
            return 1
            
        return None

    # left button press on player or entity
    def leftbuttonpressed(self,o,game):
        self.previoustext = o.leftbuttonpressed(game)#self,game.text,self.press(0))
        return self.previoustext
        
    def leftbuttonpressedwithinventoryitem(self,o,game):
        self.previoustext = o.leftbuttonpressedwithinventoryitem(game)
        return self.previoustext

#  

#     def middlebuttonpressed(self,o):
#         o.middlebutonpressed(self)

#     def rightbuttonpressed(self,o):
#         o.rightbutonpressed(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemdemon1 import *


# NOTES:
# Picturer of platform is bigger than size in world.py, so it 
# seems the player moves along

class Movingplatform1(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemdemon1())#FIXME
        self.addimage('platform1.bmp',255,255,255)
        self.counter = 0
	self.direction = "east"	
	#self.platform = 1

####### TEXT / FONT interface
    def getname(self,text):
        return text.getnullname()

#    def gettalk(self):
#        talksystem.gettalk(self)


    def doplatform(self,player,level):
	if self.direction == "west":
	    player.x -= 10		
	else:
	    player.x += 10

	print ("%d\n" % (level.roommanager.room.relativex))

        if self.direction == "west" and level.roommanager.room.relativex:
	    self.direction = "east"
	    self.counter -= 1 
	if self.direction == "west":
      	    self.counter -= 1 
	if self.direction == "east":
      	    self.counter += 1 

    def draw(self,screen):
	screen.scr.blit(self.images[0], (self.x, self.y))
        
    def update(self,room):#FIXME all level arg must be room
	1

#    def onplatform(self, player)


#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the platform."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemdemon1 import *


# NOTES:
# Picturer of platform is bigger than size in world.py, so it 
# seems the player moves along

class Movingplatformmaproom1(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)#FIXME
        self.addimage('platform11.bmp',255,255,255)
        self.counter = 0
	self.direction = "east"	
	#self.platform = 1

####### TEXT / FONT interface
    def getname(self,text):
        return text.getnullname()

#    def gettalk(self):
#        talksystem.gettalk(self)


    def doplatform(self,player,level):

      	font = pygame.font.SysFont("Vera", 32)
        level.screen.scr.blit(font.render("The lever broke!", 16, (255,255,255)), (10,10))
	self.counter += 1

	if self.direction == "west":
	   self.x -= 10
	   player.x -= 10
	#maproom.relativex += 10 
	    #player.x -= 10
	   level.roommanager.room.relativex += 10
	if self.direction == "east" and self.counter < 60:
	   #level.roommanager.room.relativex -= 10
	   self.x += 10
	   #player.x += 10	
	   player.moverightanddirect(level)	
	   level.roommanager.room.relativex -= 10
	

    def drawonmap(self,screen,maproom):
	self.draw(screen)
	#print ("456")
        self.imagescounter += 1
        if self.imagescounter == self.maximages:
            self.imagescounter = 0     
        screen.scr.blit(self.images[self.imagescounter], (self.x+maproom.relativex, self.y+maproom.relativey))
	#maproom.relativex += 10 
	#maproom.relativey += 10
	#screen.scr.blit(self.images[0], (self.x - maproom.relativex, self.y))

    def draw(self,screen):
	1
	#print ("123")
        #if r > 500:
	#    self.counter = 0 
	#    self.x -= 500
	#self.x += 1 
#above	screen.scr.blit(self.images[0], (self.x, self.y))
        
    def update(self,room):#FIXME all level arg must be room
	1

#    def onplatform(self, player)


#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the platform."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Movingwalleast(Entity):
    def __init__(self,screen,id,x,y,w,h):
        Entity.__init__(self,id,screen,x,y,w,h)
        self.addimage('wallmoving4.bmp',0,0,0)

        self.counter = 0

    def update(self,level):
        if self.counter % 100 == 0:
            self.y += 1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Movingwallnorth(Entity):
    def __init__(self,screen,id,x,y,w,h):
        Entity.__init__(self,id,screen,x,y,w,h)
        self.addimage('wallmoving1.bmp',0,0,0)

        self.counter = 0

    def update(self,level):
        if self.counter % 100 == 0:
            self.x += 1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Movingwallsouth(Entity):
    def __init__(self,screen,id,x,y,w,h):
        Entity.__init__(self,id,screen,x,y,w,h)
        self.addimage('wallmoving2.bmp',0,0,0)

        self.counter = 0

    def update(self,level):
        if self.counter % 100 == 0:
            self.x += 1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Movingwallwest(Entity):
    def __init__(self,screen,id,x,y,w,h):
        Entity.__init__(self,id,screen,x,y,w,h)
        self.addimage('wallmoving3.bmp',0,0,0)

        self.counter = 0

    def update(self,level):
        if self.counter % 100 == 0:
            self.y += 1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemmyconid import *
from entityfactory import *
from food import *

class Myconid(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemmyconid())
        self.addimage('myconid1.bmp',0,0,0)
        self.addimage('myconid2.bmp',0,0,0)
        self.addimage('myconid3.bmp',0,0,0)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getmyconidname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The myconid drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the myconid."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from myconid import *

class Myconidred(Myconid):
    def __init__(self,x,y,w,h):
        Myconid.__init__(self,x,y,w,h)
        # FIXME reset
        self.images = []
        self.imagescounter = 0
        self.maximages = 0

        self.addimage('myconidred1.bmp',0,0,0)
        self.addimage('myconidred2.bmp',0,0,0)
        self.addimage('myconidred3.bmp',0,0,0)
        self.counter = 0

    def getname(self,text):
        return text.getmyconidname()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemnutter2 import *
from entityfactory import *
from food import *

class Nutter2(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemnutter2())
        self.addimage('nutter21.bmp',255,255,255)
        self.addimage('nutter22.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getnutter2name()

#    def gettalk(self):
#        talksystem.gettalk(self)

    def update(self,room):
	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 150:
            self.counter = 0

        if self.counter < 140:
            screen.scr.blit(self.images[0], (self.x, self.y))
	else:            
	    screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def decreasehpinplayer(self, player, level):
	1 ### player.decreasehp(level)	
	
    def leftbuttonpressedwithinventoryitem(self,game):
        foobartext2 = Enemytalking.leftbuttonpressedwithinventoryitem(self,game)
	if foobartext2 and foobartext2 != "":
            return foobartext2 
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemnutter3 import *
from entityfactory import *
from food import *

class Nutter3(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemnutter3())
        self.addimage('nutter31.bmp',255,255,255)
        self.addimage('nutter32.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getnutter3name()

#    def gettalk(self):
#        talksystem.gettalk(self)

    def update(self,room):
	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 150:
            self.counter = 0

        if self.counter < 140:
            screen.scr.blit(self.images[0], (self.x, self.y))
	else:            
	    screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def decreasehpinplayer(self, player, level):
	1 ### player.decreasehp(level)	
	
    def leftbuttonpressedwithinventoryitem(self,game):
        foobartext2 = Enemytalking.leftbuttonpressedwithinventoryitem(self,game)
	if foobartext2 and foobartext2 != "":
            return foobartext2 
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemnutter4 import *
from entityfactory import *
from food import *

class Nutter4(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemnutter4())
        self.addimage('nutter41.bmp',255,255,255)
        self.addimage('nutter42.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getnutter4name()

#    def gettalk(self):
#        talksystem.gettalk(self)

    def update(self,room):
	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 150:
            self.counter = 0

        if self.counter < 140:
            screen.scr.blit(self.images[0], (self.x, self.y))
	else:            
	    screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def leftbuttonpressedwithinventoryitem(self,game):
        foobartext2 = Enemytalking.leftbuttonpressedwithinventoryitem(self,game)
	if foobartext2 and foobartext2 != "":
            return foobartext2 
        else:
            return None


    def decreasehpinplayer(self, player, level):
	1 ### player.decreasehp(level)	


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from videocodec import *
from talksystemnutternootie import *
from entityfactory import *
from food import *

class NutterNootie(Enemytalking):
    def __init__(self,x,y,w,h,screen):
        Enemytalking.__init__(self,x,y,w,h,Talksystemnutternootie())
        self.addimage('nutter-nootie1.bmp',255,255,255)
        self.addimage('nutter-nootie2.bmp',255,255,255)
        self.addimage('nutter-nootie-bamf1.bmp',255,255,255)
        self.addimage('nutter-nootie-bamf2.bmp',255,255,255)
        self.addimage('nutter-nootie-bamf3.bmp',255,255,255)
        self.addimage('nutter-nootie-bamf4.bmp',255,255,255)
        self.addimage('nutter-nootie-bamf5.bmp',255,255,255)
        self.addimage('nutter-nootie-bamf6.bmp',255,255,255)
        self.addimage('nutter-nootie-bamf7.bmp',255,255,255)
        self.images[0].set_colorkey((255,255,255)) 
        self.images[1].set_colorkey((255,255,255)) 
        self.images[2].set_colorkey((0,0,0)) 
        self.images[3].set_colorkey((0,0,0)) 
        self.images[4].set_colorkey((0,0,0)) 
        self.images[5].set_colorkey((0,0,0)) 
        self.images[6].set_colorkey((0,0,0)) 
        self.images[7].set_colorkey((0,0,0)) 
        self.images[8].set_colorkey((0,0,0)) 
        self.counter = 0
        self.counter2 = 0
	self.screen = screen

	self.videocodec = Videocodec(10,140,250,self.screen)
        image1 = pygame.image.load('nutternootieframe1.bmp').convert()
        image1.set_colorkey((0,0,0)) 
	self.videocodec.addimage(image1)
	self.videocodec.addimage(image1)
        image2 = pygame.image.load('nutternootieframe1.bmp').convert()
        image2.set_colorkey((0,0,0)) 
	self.videocodec.addimagefrequent(image1)
	self.videocodec.addimagefrequent(image2)
	self.videocodec.addimagefrequent(image1)
	self.videocodec.addimagefrequent(image2)
	self.videocodec.addimagefrequent(image1)
	self.videocodec.addimagefrequent(image2)
	self.videocodec.addimagefrequent(image1)
	self.videocodec.addimagefrequent(image2)
	self.videocodec.addimagefrequent(image1)
	self.videocodec.addimagefrequent(image2)

####### TEXT / FONT interface
    def getname(self,text):
        return text.getnutternootiename()

#    def gettalk(self):
#        talksystem.gettalk(self)

    def update(self,room):
	1

	### NOTE : talksystem 
    def leftbuttonpressed(self,game):
        if game.mouse.press(0) == 1:
            self.talkcounter += 1
            if self.talkcounter == 1:
		### TEST IMAGE
                self.currenttext = self.talksystem.gettalk(game.text)#foo
		game.video = self.videocodec
            return self.currenttext
        else:
            self.talkcounter = 0 	
            return self.currenttext

####### other methods
    def draw(self,screen):
###    def drawonmap(self,screen,maproom):
        self.counter2 += 1

        if self.counter2 >= 150:
            self.counter2 = 0

        if self.counter2 < 140 and self.counter == 0:
            screen.scr.blit(self.images[0], (self.x, self.y))
	    return
	elif self.counter == 0:            
            screen.scr.blit(self.images[1], (self.x, self.y))
            return

        self.counter += 1

        if self.counter >= 80:
	    self.hitpoints = 0
            self.counter = 0
            ###maproom.entities.list.remove(self)
	    # NOTE : move out of screen, keep object
	    self.x = -100
	    self.y = -100
            return

        if self.counter < 10:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[4], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[5], (self.x, self.y))
        elif self.counter < 60:
            screen.scr.blit(self.images[6], (self.x, self.y))
        elif self.counter < 70:
            screen.scr.blit(self.images[7], (self.x, self.y))
        elif self.counter < 80:
            screen.scr.blit(self.images[8], (self.x, self.y))



    def drawonmap(self,screen,maproom):
        self.counter2 += 1

        if self.counter2 >= 150:
            self.counter2 = 0

        if self.counter2 < 140 and self.counter == 0:
            screen.scr.blit(self.images[0], (self.x+maproom.relativex, self.y+maproom.relativey))
	    return
	elif self.counter == 0:            
            screen.scr.blit(self.images[1], (self.x+maproom.relativex, self.y+maproom.relativey))
            return

        self.counter += 1

        if self.counter >= 80:
	    self.hitpoints = 0
            self.counter = 0
            ###maproom.entities.list.remove(self)
	    # NOTE : move out of screen, keep object
	    self.x = -100
	    self.y = -100
            return

        if self.counter < 10:
            screen.scr.blit(self.images[1], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 20:
            screen.scr.blit(self.images[2], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 30:
            screen.scr.blit(self.images[3], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 40:
            screen.scr.blit(self.images[4], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 50:
            screen.scr.blit(self.images[5], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 60:
            screen.scr.blit(self.images[6], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 70:
            screen.scr.blit(self.images[7], (self.x+maproom.relativex, self.y+maproom.relativey))
        elif self.counter < 80:
            screen.scr.blit(self.images[8], (self.x+maproom.relativex, self.y+maproom.relativey))
        

#    def leftbuttonpressed(self,mouse,text):
#        return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def usedracolichspellbook(self, game):
	counter = 30
        print "You use the Dracolich Spellbook on Nutter Nootie"
	self.remove(game.level.roommanager.room.entities)	
        pygame.display.update()
        # kickstart end scene
	self.counter = 1
	while counter > 0:
        	game.screen.scr.blit(game.font.render("BAMF!", 43, (255,255,255)), (100,100))
                pygame.display.update()
		counter -= 1
        game.gamepoints.set("usedracolichspellbookonnootie") 

    def decreasehpinplayer(self, player, level):
	1 ### player.decreasehp(level)	
	
    def leftbuttonpressedwithinventoryitem(self,game):
        foobartext2 = Enemytalking.leftbuttonpressedwithinventoryitem(self,game)
	if foobartext2 and foobartext2 != "":
            return foobartext2 
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemnutter import *
from entityfactory import *
from food import *

class Nutter(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemnutter())
        self.addimage('nutter1.bmp',255,255,255)
        self.addimage('nutter2.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getnuttername()

#    def gettalk(self):
#        talksystem.gettalk(self)

    def update(self,room):
	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 150:
            self.counter = 0

        if self.counter < 140:
            screen.scr.blit(self.images[0], (self.x, self.y))
	else:            
	    screen.scr.blit(self.images[1], (self.x, self.y))
        

#    def leftbuttonpressed(self,mouse,text):
#        return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def decreasehpinplayer(self, player, level):
	1 ### player.decreasehp(level)	

    def leftbuttonpressedwithinventoryitem(self,game):
        foobartext2 = Enemytalking.leftbuttonpressedwithinventoryitem(self,game)
	if foobartext2 and foobartext2 != "":
            return foobartext2 
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#from talksystemmyconid import *
from entityfactory import *
from food import *
from bouncer import *

class Oozebig(Bouncer):
    def __init__(self,x,y,w,h, boxes):
        Bouncer.__init__(self,x,y,w,h,Talksystemmyconid())
        self.addimage('oozebig1.bmp',255,255,255)
        self.addimage('oozebig1.bmp',255,255,255)
        self.addimage('oozebig1.bmp',255,255,255)
        self.counter = 0
	self.direction = 1 
	self.boxes = boxes
####### TEXT / FONT interface
    def getname(self,text):
        return text.getoozebigname()



####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 30:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
    
# RANDOM MOVES    
    def update(self,room):#FIXME all level arg must be room

        r = randint(0,3)
        if r == 0:
            self.x += 1
        if r == 1:
            self.x -= 1
        if r == 2:
            self.y += 1
        if r == 3:
            self.y -= 1



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Ooze(Enemy):
    def __init__(self,screen,id,x,y,w,h):
        Enemy.__init__(self,id,screen,x,y,w,h)
        self.addimage('player1-50x50.bmp',255,255,255)


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from entity import *
import random
from utility import *
from talksystemorcblue1 import *

class Orcblue(Enemytalking):#FIXME emytalking):
    "Blue Orc"
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemorcblue1())

        self.addimage('orcblue1.bmp',255,255,255)
        
#        self.counter = 0
        self.direction = "south"
        self.hitpoints = 1

        self.casting = None
        self.castingcounter = 0

        self.dungeonnumber = "1"#dungeonnumber
        self.keynumber = "1"#keynumber


    def draw(self,screen):

	screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):
       1; 
            
    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()

    def remove(self,list):
#        string = "You have killed boss 1 - dungeon 2\n"




        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

            
        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None


        if self.hitpoints == 0:

            f = open("./workfile",'r')
            for line in f:
                s += line
                
            f = open("./workfile",'w')
            
            f.write(s)
            f.write(string)
            f.write("\n")

            list.remove(self)

            return 1

    def hit(self):
        self.hitpoints -= self.decreasehp


    def readkoboldmage(self,list):
        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ kobold mage already neutralised"
#            self.removeallenemies()
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getblueorcname()
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemorcguardian import *
from entityfactory import *
from food import *

class Orcguardian2(Enemytalking):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemorcguardian())
        self.addimage('orcguardian1.bmp',0,0,0)
        self.addimage('orcguardian2.bmp',0,0,0)
        self.addimage('orcguardian1.bmp',0,0,0)
        self.addimage('orcguardian3.bmp',0,0,0)
        self.counter = 0

	self.direction = "right"
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getorcguardianname()

#### NEW FUNCTION
    def collisionboxesnew(self,room):
        o = self.collisionlist(room.boxes)
        if o:
            self.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):
	if self.entangled:
		return
	if self.collisionboxesnew(room):### JUMP
		if self.direction == "left":
			self.x += 2
			self.direction = "right"
		elif self.direction == "right":
			self.x -= 2
			self.direction = "left"

	if self.direction == "left":
		self.x -= 1
	elif self.direction == "right":
		self.x += 1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The orcguardian drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the knight."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def bounceback(self):
	1

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemorcguardian import *
from entityfactory import *
from food import *

class Orcguardian(Enemytalking):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemorcguardian())
        self.addimage('orcguardian1.bmp',0,0,0)
        self.addimage('orcguardian2.bmp',0,0,0)
        self.addimage('orcguardian1.bmp',0,0,0)
        self.addimage('orcguardian3.bmp',0,0,0)
        self.counter = 0

	self.direction = "down"
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getorcguardianname()

#### NEW FUNCTION
    def collisionboxesnew(self,room):
        o = self.collisionlist(room.boxes)
        if o:
            #self.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):
	if self.entangled:
		return
	if self.collisionboxesnew(room):### JUMP
		if self.direction == "up":
			self.y += 3 
			self.direction = "down"
		elif self.direction == "down":
			self.y -= 3
			self.direction = "up"

	if self.direction == "up":
		self.y -= 1
	elif self.direction == "down":
		self.y += 1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The orcguardian drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the knight."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def bounceback(self):
        if self.direction == "up":#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == "down":#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == "left":#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == "right":#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	#r = randint(1,4)
	#self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

#
# Hut on pillars
#
class Orchut2(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('orchut2.bmp',255,255,255)

    def getname(self,text):
        return text.getorchutname()


    def update(self,level):
        1

    def remove(self,list):
        1#list.remove(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

#
# Hut on pillars
#
class Orchut3(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('orchut3.bmp',255,255,255)

    def getname(self,text):
        return text.getorchutname()


    def update(self,level):
        1

    def remove(self,list):
        1#list.remove(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Orchut(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('orchut1.bmp',255,255,255)

    def getname(self,text):
        return text.getorchutname()


    def update(self,level):
        1

    def remove(self,list):
        1#list.remove(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemorcpaladin import *

class Orcpaladin(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemorcpaladin())
        self.addimage('orcpaladin.bmp',255,255,255)
        self.addimage('orcpaladin.bmp',255,255,255)
        self.addimage('orcpaladin.bmp',255,255,255)
        self.addimage('orcpaladin.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getorcpaladinname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the orc paladin."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#from bouncer import *
from enemytalking import *
from talksystemorcswordsmanblue import *
from entityfactory import *
from food import *

class Orcswordsmanblue(Enemytalking):#Bouncer):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemorcswordsmanblue())
        self.addimage('orcswordsmanblue1.bmp',255,255,255)
        self.addimage('orcswordsmanblue1.bmp',255,255,255)
        self.addimage('orcswordsmanblue1.bmp',255,255,255)
        self.counter = 0

	self.direction = 1 
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getorcswordsmanbluename()

#    def gettalk(self):
#        talksystem.gettalk(self)
#    def update(self,room):
#	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The orcswordsmanblue drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the orcswordsmanblue."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room
	ri = randint(0,42)
	if ri == 14:
	    r = randint(1,4)
	    self.direction = r
	o = None
	o = self.collisionboxes()

	if o:
	    r = randint(0,40)
	    if r < 2:
	        self.bounceback(None) 	
        if self.direction == 1:#north
	     self.y -= 1
        elif self.direction == 3:#south
 	     self.y += 1
        elif self.direction == 4:#west
             self.x -= 1
        elif self.direction == 2:#east
	     self.x += 1

    def bounceback(self,level):
        if self.direction == 1:#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == 3:#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == 4:#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == 2:#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	r = randint(1,4)
	self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from entity import *
import random
from utility import *
from talksystemvillageorc1 import *

class Orcvillage(Enemytalking):#FIXME emytalking):
    "Orc in village"
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemvillageorc1())

        self.addimage('orcvillage1.bmp',255,255,255)
        
#        self.counter = 0
        self.direction = "south"
        self.hitpoints = 1

        self.casting = None
        self.castingcounter = 0

        self.dungeonnumber = "1"#dungeonnumber
        self.keynumber = "1"#keynumber


    def draw(self,screen):

	screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):
       1; 
            
    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()

    def remove(self,list):
#        string = "You have killed boss 1 - dungeon 2\n"




        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

            
        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None


        if self.hitpoints == 0:

            f = open("./workfile",'r')
            for line in f:
                s += line
                
            f = open("./workfile",'w')
            
            f.write(s)
            f.write(string)
            f.write("\n")

            list.remove(self)

            return 1

    def hit(self):
        self.hitpoints -= self.decreasehp


    def readkoboldmage(self,list):
        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ kobold mage already neutralised"
#            self.removeallenemies()
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getblueorcname()
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from entity import *
import random
from utility import *
from talksystemvillageorc2 import *

class Orcvillage2(Enemytalking):#FIXME emytalking):
    "Orc 2 in village"
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemvillageorc2())

        self.addimage('orcvillage2.bmp',255,255,255)
        
#        self.counter = 0
        self.direction = "south"
        self.hitpoints = 1

        self.casting = None
        self.castingcounter = 0

        self.dungeonnumber = "1"#dungeonnumber
        self.keynumber = "1"#keynumber


    def draw(self,screen):

	screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):
       1; 
            
    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()

    def remove(self,list):
#        string = "You have killed boss 1 - dungeon 2\n"




        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

            
        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None


        if self.hitpoints == 0:

            f = open("./workfile",'r')
            for line in f:
                s += line
                
            f = open("./workfile",'w')
            
            f.write(s)
            f.write(string)
            f.write("\n")

            list.remove(self)

            return 1

    def hit(self):
        self.hitpoints -= self.decreasehp


    def readkoboldmage(self,list):
        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ kobold mage already neutralised"
#            self.removeallenemies()
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getvillageorcmagename()
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from entity import *
import random
from utility import *
from talksystemvillageorc3 import *

class Orcvillage3(Enemytalking):#FIXME emytalking):
    "Orc in village"
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemvillageorc3())

        self.addimage('orcvillage3.bmp',255,255,255)
        
#        self.counter = 0
        self.direction = "south"
        self.hitpoints = 1

        self.casting = None
        self.castingcounter = 0

        self.dungeonnumber = "1"#dungeonnumber
        self.keynumber = "1"#keynumber


    def draw(self,screen):

	screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):
       1; 
            
    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()

    def remove(self,list):
#        string = "You have killed boss 1 - dungeon 2\n"




        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

            
        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None


        if self.hitpoints == 0:

            f = open("./workfile",'r')
            for line in f:
                s += line
                
            f = open("./workfile",'w')
            
            f.write(s)
            f.write(string)
            f.write("\n")

            list.remove(self)

            return 1

    def hit(self):
        self.hitpoints -= self.decreasehp


    def readkoboldmage(self,list):
        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ kobold mage already neutralised"
#            self.removeallenemies()
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getblueorcname()
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from entity import *
import random
from utility import *
from talksystemorcvillagewarrior1 import *

class Orcvillagewarrior1(Enemytalking):#FIXME emytalking):
    "Orc Warrior in village"
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemorcvillagewarrior1())

        self.addimage('orcvillagewarrior1.bmp',255,255,255)
        
#        self.counter = 0
        self.direction = "south"
        self.hitpoints = 1

        self.casting = None
        self.castingcounter = 0

        self.dungeonnumber = "1"#dungeonnumber
        self.keynumber = "1"#keynumber


    def draw(self,screen):

	screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):
       1; 
            
    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()

    def remove(self,list):
#        string = "You have killed boss 1 - dungeon 2\n"




        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

            
        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None


        if self.hitpoints == 0:

            f = open("./workfile",'r')
            for line in f:
                s += line
                
            f = open("./workfile",'w')
            
            f.write(s)
            f.write(string)
            f.write("\n")

            list.remove(self)

            return 1

    def hit(self):
        self.hitpoints -= self.decreasehp


    def readkoboldmage(self,list):
        string = "You have killed a kobold mage "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ kobold mage already neutralised"
#            self.removeallenemies()
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getorcvillagewarriorname()
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from bomb import *

from entity import *

class Player:
    "Player"
    def __init__(self):
	#Entity.__init__(self,200,210,50,50)
        self.x = 200#400
        self.y = 210#100
        self.w = 50
        self.h = 50
        self.direction = "north"
        self.images = []
        self.image1 = pygame.image.load('player1-50x50.bmp').convert()
        self.image2 = pygame.image.load('player2-50x50.bmp').convert()
        self.image3 = pygame.image.load('player1-50x50.bmp').convert()
        self.image4 = pygame.image.load('player3-50x50.bmp').convert()
        self.image5 = pygame.image.load('playerwithswordleft1.bmp').convert()
        self.image6 = pygame.image.load('playerwithsword1.bmp').convert()

        self.image1.set_colorkey((255,255,255)) 
        self.image2.set_colorkey((255,255,255)) 
        self.image3.set_colorkey((255,255,255)) 
        self.image4.set_colorkey((255,255,255)) 
        self.image5.set_colorkey((255,255,255)) 
        self.image6.set_colorkey((255,255,255)) 

        self.lifeimage = pygame.image.load('life1.bmp').convert()
        self.lifeimage.set_colorkey((255,255,255)) 
        self.manaimage = pygame.image.load('mana1.bmp').convert()
        self.manaimage.set_colorkey((255,255,255)) 

        self.imageindex = 0

        self.addimages()

        self.bombidcounter = 10000

        self.hitpoints = 30 
        self.decreasehitpoints = 1
        self.manapoints = 30 
        self.decreasemanapoints = 1

        self.talkcounter = 0
        self.currenttext = ""

        self.blackimage1 = pygame.image.load('player1-madblack-50x50.bmp').convert()
        self.blackimage1.set_colorkey((255,255,255)) 
        self.black = None
        self.madcounter = 0
	self.invisible = 0

    def drawlife(self, screen):
 	i = self.hitpoints 
	while i > 0:
	   i -= 1
           screen.scr.blit(self.lifeimage, (10+i*10,2))
	    
    def drawmana(self, screen):
 	i = self.manapoints 
	while i > 0:
	   i -= 1
           screen.scr.blit(self.manaimage, (10+i*10,24))
	     

    def addimages(self):
        self.images.append(self.image1)
        self.images.append(self.image2)
        self.images.append(self.image3)
        self.images.append(self.image4)
        self.images.append(self.image5)
        self.images.append(self.image6)

    def warp(self,x,y):
        self.x = x
        self.y = y


    def moveupanddirect(self,level):
        level.roommanager.room.moveup(self)

    def movedownanddirect(self,level):
        level.roommanager.room.movedown(self)

    def moveleftanddirect(self,level):
        level.roommanager.room.moveleft(self)

    def moverightanddirect(self,level):
        level.roommanager.room.moveright(self)


    def moveupanddirect1(self):
        self.direction = "north"
        self.y = self.y - 12
        self.imageindex = self.imageindex + 1

    def movedownanddirect1(self):
        self.direction = "south"
        self.y = self.y + 12
        self.imageindex = self.imageindex + 1

    def moveleftanddirect1(self):
        self.direction = "west"
        self.x = self.x - 12
        self.imageindex = self.imageindex + 1

    def moverightanddirect1(self):
        self.direction = "east"
        self.x = self.x + 12
        self.imageindex = self.imageindex + 1

    def moveup(self):
        self.y = self.y - 12

    def movedown(self):
        self.y = self.y + 12

    def moveleft(self):
        self.x = self.x - 12

    def moveright(self):
        self.x = self.x + 12


    def bounceback(self,level):
        if self.direction == "north":
            self.movedownanddirect(level)
            #self.movedown()
        elif self.direction == "south":
            self.moveupanddirect(level)
            #self.moveup()
        elif self.direction == "west":
            self.moverightanddirect(level)
            #self.moveright()
        elif self.direction == "east":
            self.moveleftanddirect(level)
            #self.moveleft()


    def draw(self):
        self.imageindex = self.imageindex + 1
	if self.invisible:
            if self.imageindex > 3:
                self.imageindex = 0
            return self.images[self.imageindex]

        if self.black:
            r = randint(0,100)
            if r < 1 or self.madcounter >= 1:
                self.madcounter += 1

                if self.madcounter >= 10:
                    self.madcounter = 0

                return self.blackimage1
 
        if self.imageindex > 3:
            self.imageindex = 0

        return self.images[self.imageindex]
       
    def drawswordleft(self):
	return self.images[4]	 
    
    def drawswordright(self):
	return self.images[5]	 

    def dropbomb(self,level):
        level.roommanager.room.addsprite(Bomb(self.x,self.y,80,80))

    def decreasehp(self,level):
	print ("player is hit!")
        self.hitpoints -= self.decreasehitpoints

        if self.hitpoints <= 0:
            level.setgameover()
    
    def increasehp(self):
	if self.hitpoints < 30:
            self.hitpoints += 5 

    def collisionplayer(self,mouse):
        if mouse.x >= self.x and mouse.x <= self.x + self.w and mouse.y >= self.y and mouse.y <= self.y + self.h:   	
              return self
        return None

    def processorrelativex(self,o,relx):
        return o.x - relx

    def processorrelativey(self,o,rely):
        return o.y - rely

    def collisionplayerrelative(self,mouse,relx,rely):
        px = self.processorrelativex(self,relx)
        py = self.processorrelativey(self,rely)

        x = self.processorrelativex(mouse, relx)
        y = self.processorrelativey(mouse, rely)
        if x >= px and x <= px + self.w and y >= py and y <= py + self.h:
              return self
        return None

    def collisionlistsword(self,list):
        return self.collisionlist2(self,list)
    
    def collisionlisttri1(self,list):
        return self.collisionlisttri11(self,list)
    def collisionlisttri2(self,list):
        return self.collisionlisttri12(self,list)
    def collisionlisttri3(self,list):
        return self.collisionlisttri13(self,list)
    def collisionlisttri4(self,list):
        return self.collisionlisttri14(self,list)
    
    # GEN PROC left upper triangular boxes
    def collisionlisttri11(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            if o:
 	    	 x1 = o.x1
 	         x2 = o.x2
 	    	 y1 = o.y1
 	         y2 = o.y2
		 x = collider.x
		 y = 480-collider.y ## NOTE collider.y is negative
	    	 rico =  (y2-y1)/(x2-x1) ## NOTE1 rico -
		 value = y - y1 - rico * (x - x1) 
		 #print "++ Collision with rico=%d" % rico 
		 #print "++ Collision with y1=%d" % y1 
		 #print "++ Collision with x1=%d" % x1 
		 #print "-- collider.y =%d" % collider.y
	         if value > 0 and -collider.y > y1 and -collider.y < y2:###NOTE1

                     return o
        return None

    # GEN PROC right upper triangular boxes
    def collisionlisttri12(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            if o:
 	    	 x1 = o.x1
 	         x2 = o.x2
 	    	 y1 = o.y1
 	         y2 = o.y2
		 x = collider.x
		 y = 480-collider.y
	    	 rico = (y2-y1)/(x2-x1) ## NOTE1 rico -
		 value = y - y1 - rico * (x - x1) 
		 #print " Collision with rico=%d" % rico 
		 #print " Collision with y1=%d" % y1 
		 #print " Collision with x1=%d" % x1 
		 #print " collider.y =%d" % collider.y
	         if value > 0 and -collider.y > y1 and -collider.y < y2:###NOTE1
                     return o
        return None

    # GEN PROC right down triangular boxes
    def collisionlisttri13(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            if o:
 	    	 x1 = o.x1
 	         x2 = o.x2
 	    	 y1 = o.y1
 	         y2 = o.y2
		 x = collider.x
		 y = 480-collider.y
	    	 rico =  - (y2-y1)/(x2-x1) ## NOTE1 rico -
		 value = y - y1 - rico * (x - x1) 
		 print "++ Collision with rico=%d" % rico 
		 print "++ Collision with y1=%d" % y1 
		 print "++ Collision with x1=%d" % x1 
	         if value < 0:
                     return o
        return None

    # GEN PROC left down triangular boxes
    def collisionlisttri14(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            if o:
 	    	 x1 = o.x1
 	         x2 = o.x2
 	    	 y1 = o.y1
 	         y2 = o.y2
		 x = collider.x
		 y = 480-collider.y
	    	 rico =  - (y2-y1)/(x2-x1) ## NOTE1 rico -
		 value = y - y1 - rico * (x - x1) 
		 print "++ Collision with rico=%d" % rico 
		 print "++ Collision with y1=%d" % y1 
		 print "++ Collision with x1=%d" % x1 
	         if value > 0:
                     return o
        return None

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h:   	
                    return o
        return None

	# SWORD COLLISON
    def collisionlist2(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x+30 >= o.x and collider.x <= o.x + o.w+30 and collider.y +30>= o.y and collider.y <= o.y + o.h +30:   	
                    return o
        return None

    #FIXME put in Utitlities
    def processorrelativex(self,o,relx):
        return o.x - relx

    def processorrelativey(self,o,rely):
        return o.y - rely
    
    def collisionlistrelative(self,list,relx,rely):
        return self.collisionlistrelative1(self,list,relx,rely)

    # GEN PROC
    def collisionlistrelative1(self,collider,list,relx,rely):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)

            if o:
       
                #FIXME1 o.x <-> self.relativex
                x = o.x - 12#self.processorrelativex(o,relx)
                y = o.y - 12#self.processorrelativey(o,rely)
                px = self.processorrelativex(self,relx)
                py = self.processorrelativey(self,rely)

#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,px,py)
		# NOTE : +24 for better sword collision
                if px + 12 >= x and px <= x + o.w + 12 and py + 12 >= y and py <= y + o.h + 12:   	
                    return o
        return None

    def leftbuttonpressed(self,game):
        if game.mouse.press(0) == 1:
            self.talkcounter += 1
            #print "keypress on player"
            if self.talkcounter == 1:
                1#self.currenttext = self.talksystem.gettalk(text)#foo
            return self.currenttext
        else:
            self.talkcounter = 0 	
            return self.currenttext


    def leftbuttonpressedwithinventoryitem(self,game):#mouse,text,press0,item):
        if game.mouse.press(0) == 1:
            self.talkcounter += 1
            #print "keypress with item on player"
            if game.inventoryitem:
                game.inventoryitem.use(self,game)
            return 1
        else:
            self.talkcounter = 0 	
            return None#self.currenttext

#        print "+++ left button press on player"
#        return None

    def usedracolichspellbook(self,game):
	print("You use the dracolich spellbook.")
	self.manapoints -= self.decreasemanapoints
        self.setblackplayer(game)
        x = randint(0,500)
        y = randint(0,300)
	if self.manapoints > 0:
           game.level.roommanager.room.summonskeletonunderplayercommand(x,y)

    def usenootiespellbook(self,game):
	print("You use Nootie's spellbook.")
	self.manapoints -= self.decreasemanapoints
        self.setblackplayer(game)
        x = randint(0,500)
        y = randint(0,300)
	if self.manapoints > 0:
           game.level.roommanager.room.summonskeletonunderplayercommand(x,y)


    def usescrollinvisibility(self,game):
	print("You become invisible.")
        self.setinvisibleplayer(game)

    def usebomb(self,game):
	1

    def useyellowring(self,game):
        return game.text.getnothinghappens()

    def usechest1(self,game):
	print("You drink chest1.")
        string = "You drank the healing potion - chest 1"
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
	    ###if list:
            ###    game.inventory.list.remove(self)
	    ###FIXME0if game.inventory.list
            return None
        f = open("./workfile",'r')

	for line in f:
		s += line
	f = open("./workfile", 'w')       
 
        f.write(s)
        f.write(string)
        f.write("\n")

	self.hitpoints = 30
        return 1
 
    def usechestmanapotion(self,game):
	print("You drink a mana potion chest.")
        string = "You drank the mana potion - chest 2"
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
	    ###if list:
            ###    game.inventory.list.remove(self)
	    ###FIXME0if game.inventory.list
            return None
        f = open("./workfile",'r')

	for line in f:
		s += line
	f = open("./workfile", 'w')       
 
        f.write(s)
        f.write(string)
        f.write("\n")

	self.manapoints = 30
        return 1
 
	
	
    def setblackplayer(self,game):

        self.black = 1
        self.madcounter = 0

        self.images = []
        self.image1 = pygame.image.load('player1-black-50x50.bmp').convert()
        self.image2 = pygame.image.load('player2-black-50x50.bmp').convert()
        self.image3 = pygame.image.load('player1-black-50x50.bmp').convert()
        self.image4 = pygame.image.load('player3-black-50x50.bmp').convert()

        self.image1.set_colorkey((255,255,255)) 
        self.image2.set_colorkey((255,255,255)) 
        self.image3.set_colorkey((255,255,255)) 
        self.image4.set_colorkey((255,255,255)) 

        self.addimages()



    def setinvisibleplayer(self,game):
	print ("set invisibile player")
        self.invisible = 1

        self.images = []
        self.image1 = pygame.image.load('playerinvisible1-50x50.bmp').convert()
        self.image2 = pygame.image.load('playerinvisible2-50x50.bmp').convert()
        self.image3 = pygame.image.load('playerinvisible3-50x50.bmp').convert()

        self.image1.set_colorkey((255,255,255)) 
        self.image2.set_colorkey((255,255,255)) 
        self.image3.set_colorkey((255,255,255)) 

        self.addimages()


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Ringblue(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('ringblue1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a blue ring "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):
        string = "You have a ring "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ Seraphim ring (blue) registered"
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getringbluename()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Ringyellow(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('ringyellow1.bmp',255,255,255)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber
	self.flag = 0 

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a yellow ring "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):
        string = "You have a yellow ring "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

	if self.flag:
		return None

        if Utilities().readandfindstring(string):
            ### print "+++ Seraphim yellow ring registered"
	    self.flag = 1
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getringyellowname()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from list import *
from box import *
from exitbox import *
from ooze import *
from ent import *
from tree import *
from tree2 import *
from tree3 import *
from movingwallnorth import *
from movingwallsouth import *
from movingwallwest import *
from movingwalleast import *
from treestone import *
from entstone import *
from bat import *
from skeleton import *
from skeleton2 import *
from skeletonunderplayercommand import *
from dragon import *
from dracolich import *

from utility import *

from entityfactory import *

import inspect

class Roomchbg:
    ""
    def __init__(self):
        self.initroom()
        self.entityfactory = None
	self.counter = 0
	self.background = List()

    # FIXME
    def addfactory(self,factory):
        frame = inspect.currentframe()
        try:
            frame != None
        finally:
            factory.add(self)

    def loadroom(self,roommanager):
         roommanager.loadroom(self)

    def updatelist(self,list):
        for el in list.list:
            if el:
                el.update(self)

    def addbox(self,x,y,w,h):
        self.boxes.add(Box(x,y,w,h))

    def addexit(self,x,y,w,h,roomid,newx,newy,room):
         self.exits.add(Exitbox(x,y,w,h,roomid,newx,newy,room))

    def addentitythroughfactory(self,room):
        1#FIXME

    def addentity(self,entity):
        if entity:
            self.entities.add(entity)

    def addenemy(self,enemy):
        self.addentity(enemy)

    def addsprite(self,sprite):
        self.addentity(sprite)

    def loadwalls(self):
        1

    def initroom(self):
        self.totalboxes = 0
        self.boxes = List()
        self.totalexits = 0
        self.exits = List()
        self.background = None
        self.entities = List()
        self.idcounter = 0
        self.night = 0
        self.loadwalls()
	

    def draw(self,screen):
        screen.scr.blit(self.background.getwithindex(0), (0, 0))
#	self.counter += 1
#	if self.counter < 10:
#            screen.scr.blit(self.background.getwithindex(0), (0, 0))
#	elif self.counter < 20:
#            screen.scr.blit(self.background.getwithindex(1), (0, 0))
#	elif self.counter < 30:
#            screen.scr.blit(self.background.getwithindex(2), (0, 0))
#	else:
#	    self.counter = 0
      #  screen.drawonmap(self)
#    def draw(self,screen):
#        screen.scr.blit(self.background, (0, 0))
#        screen.draw(self.entities)

#    def auxdraw(self):
#	self.auxdraw(self.)
#        screen.scr.blit(self.background, (0, 0))
#        screen.draw(self.entities)

    def update(self,player,level,swordplay):#unsused level
        self.updatelist(self.entities)

        o = player.collisionlist(self.entities)
        if o:
#	    print ("%d" % (o.platform))
	    if swordplay != 0:
		print ("--------SWORDPLAY")
		#FIXME see in enemy.py o.hitpoints -= 1
        	if o.hitpoints <= 0:
            	    self.entities.remove(o)    
	    else:
	        o.dofood(player) 
	        o.doplatform(player,level) 
                player.bounceback(level)
                o.decreasehpinplayer(player, level)
	    o.remove(self.entities)
 
    def collisionplayer(self,mouse,player):
        mouse.collisionplayer(player)

    def domouse(self,game):
        # Collide mouse with player

        p = game.domouseonplayer(self)
        if p:
            foo = game.leftbuttonpressed(game.player)
            if foo:
                return
            
        # Collide mouse with entities
        o = None
        o = game.collisionlistonmouse(self.entities)
        if o:
            foo = game.leftbuttonpressed(o)
#            print foo
            if foo:
                game.screen.scr.blit(game.font.render(foo, 16, (255,255,255)), (10,10))
#                print foo
            else:
                game.screen.scr.blit(game.font.render(o.getname(game.text), 10, (0,0,0)), (game.mouse.x+10,game.mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)
            


    def domouseinventory(self,game):#,screen,mouse,font,text,item,player):
        # Collide mouse with player
        p = game.domouseonplayer(self)#game.mouse.collisionplayer(game)
        if p:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(game.player,game)
            if foo:
                return 1

        # Collide mouse with entities
        o = None
        o = game.collisionlistonmouse(self.entities)
        if o and game.inventoryitem:
            foo = game.mouse.leftbuttonpressedwithinventoryitem(o,game)#.text,game.inventoryitem)
            if foo:
                return 1

        if not o and game.mouse.press(0):
            return 1

        return None
#             if foo:
#                 screen.scr.blit(font.render(foo, 16, (255,255,255)), (10,10))
# #                print foo
#             else:
#                 screen.scr.blit(font.render(o.getname(text), 10, (0,0,0)), (mouse.x+10,mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)



    def moveup(self, player):
        player.moveupanddirect1()

    def movedown(self, player):
        player.movedownanddirect1()

    def moveleft(self, player):
        player.moveleftanddirect1()

    def moveright(self, player):
        player.moverightanddirect1()


######## COLLISION CODE

    def collisionlistbomb(self,bomb,list):
#         for i in range(0,list.length):
#             o = None
#             o = list.getlistobject(o)

        for o in list.list:
            if o and o.x >= bomb.x - bomb.w and o.x <= bomb.x + bomb.w and o.y >= bomb.y - bomb.h and o.y <= bomb.y + bomb.h:
                return o
        return None


    def collisionexits(self,player,roommanager):
        o = player.collisionlist(self.exits)

        if o:

            print 'foo x=%d,y=%d px=%d py=%d' % (o.x,o.y,player.x,player.y)

            o.room.loadroom()
            roommanager.room = o.room
            player.warp(o.newx,o.newy)
            return 1
        return None

    def collisionboxes(self,player):
        o = player.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None


    def collisionandremoveenemieswithbomb(self, bomb):
        o = self.collisionlistbomb(bomb,self.entities)
        if o:
            o.hit()
            o.remove(self.entities)
            self.entities.remove(o)
            
    def summonskeletonunderplayercommand(self,x,y):
        self.addenemy(Skeletonunderplayercommand(x,y,50,50))


    def summonskeleton(self,x,y):
        self.addenemy(Skeleton2(x,y,50,50))

    def removeallenemies(self):
        self.entities = List()
            
    def removeallentities(self):
        self.entities = List()



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from room import *

class Roomdungeon1(Room):
    ""
    def __init__(self):
       Room.__init__(self)
       self.loadwalls()

    def loadwalls(self):
        # NORTH WALL
        self.addbox(0,0,640,80)
        # SOUTH WALL
        self.addbox(0,400,640,80)
        # WEST WALL
        self.addbox(0,0,60,480)
        # EAST WALL
        self.addbox(580,0,60,480)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from room import *

class Roomdungeon2(Room):
    ""
    def __init__(self):
       Room.__init__(self)
       self.loadwalls()

    def loadwalls(self):
        
        # NORTH WALL
        self.addbox(0,0,640,80)
        # SOUTH WALL
        self.addbox(0,400,640,80)
        # WEST WALL
        self.addbox(0,0,60,480)
        # EAST WALL
        self.addbox(580,0,60,480)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from map import *

from key import *
from lockeddoornorth import *
from lockeddoorsouth import *
from lockeddooreast import *
from lockeddoorwest import *

from world import *
from mapworld import *

class Roommanager:
    "Room manager"
    def __init__(self, screen):
	self.screen = screen
        self.room = None

        self.load(Room1world(self))
#        self.load(DungeonundertreeCastle2(0,0,self))
#        self.load(NutGrove4(0,0,self))
#        self.load(Cavernsofdespair3(0,0,self))
#        self.load(Cavernsofdespair4(0,0,self))
#        self.load(Roombirdforest(-20,-200,self))

#        self.load(Dungeonwaterlowermountains1(-1600,-1000,self))

#        self.load(Worldmapinsidetemple5(-100,-300,None))
#        self.load(Worldmapinsidetemple8(None))###self.room.roomman))
#        self.load(Dungeonwaterlower2(None))
### Draoclich's dungeon room 1
#	self.load(Room1dungeon2(None))
### room with yellow seraphim ring use
### You have a yellow ring 1 - dungeon 3
#        self.load(Dungeonwater5(-200,-100,None))
### assassin's room with scroll
#        self.load(Dungeonwaterlower2(None))###-200,-100,None))

#        self.load(Roomdungeonwatercherubs(None))
#        self.load(Worldmaproom3water(-1000,-100, None))
        # other entries in the game :

#        self.load(Room9dungeon2())
#        self.load(Worldmaproom1(0,-520))
     
    def load(self,room):
        self.room = room.loadroom()

    def getroom(self):
        return self.room
    

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from list import *
from box import *
from boxtri import *
from exitbox import *
from ooze import *
from ent import *
from tree import *
from tree2 import *
from tree3 import *
from movingwallnorth import *
from movingwallsouth import *
from movingwallwest import *
from movingwalleast import *
from treestone import *
from entstone import *
from bat import *
from skeleton import *
from skeleton2 import *
from skeletonunderplayercommand import *
from dragon import *
from dracolich import *

from utility import *

from entityfactory import *

import inspect

class Room:
    ""
    def __init__(self):
	## NOTE: PRE INIT
        self.totalboxes = 0
        self.boxes = List()
        self.triboxes1 = List() ## left up 
        self.triboxes2 = List() ## right up
        self.triboxes3 = List() ## right down
        self.triboxes4 = List() ## left down
        self.totalexits = 0
        self.exits = List()
        self.background = None
        self.entities = List()
        self.idcounter = 0
        self.night = 0
        self.loadwalls()
	
        self.initroom()
        self.entityfactory = None

    # FIXME
    def addfactory(self,factory):
        frame = inspect.currentframe()
        try:
            frame != None
        finally:
            factory.add(self)

    def loadroom(self,roommanager):
         roommanager.loadroom(self)

    def updatelist(self,list):
        for el in list.list:
            if el:
                el.update(self)

    def addbox(self,x,y,w,h):
        self.boxes.add(Box(x,y,w,h))

    def addtribox1(self,x1,y1,x2,y2):
        self.triboxes1.add(TriBox(x1,y1,x2,x2))
    def addtribox2(self,x1,y1,x2,y2):
        self.triboxes2.add(TriBox(x1,y1,x2,x2))
    def addtribox3(self,x1,y1,x2,y2):
        self.triboxes3.add(TriBox(x1,y1,x2,x2))
    def addtribox4(self,x1,y1,x2,y2):
        self.triboxes4.add(TriBox(x1,y1,x2,x2))

    def addexit(self,x,y,w,h,roomid,newx,newy,room):
         self.exits.add(Exitbox(x,y,w,h,roomid,newx,newy,room))

    def addentitythroughfactory(self,room):
        1#FIXME

    def addentity(self,entity):
        if entity:
            self.entities.add(entity)

    def addenemy(self,enemy):
        self.addentity(enemy)

    def addsprite(self,sprite):
        self.addentity(sprite)

    def loadwalls(self):
        1

    def initroom(self):
        self.totalboxes = 0
        self.boxes = List()
        self.triboxes1 = List() ## left up 
        self.triboxes2 = List() ## right up
        self.triboxes3 = List() ## right down
        self.triboxes4 = List() ## left down
        self.totalexits = 0
        self.exits = List()
        self.background = None
        self.entities = List()
        self.idcounter = 0
        self.night = 0
        self.loadwalls()
	

    def draw(self,screen):
        screen.scr.blit(self.background, (0, 0))
        screen.draw(self.entities)

#    def auxdraw(self):
#	self.auxdraw(self.)
#        screen.scr.blit(self.background, (0, 0))
#        screen.draw(self.entities)

    def update(self,player,level,swordplay):#unsused level
        self.updatelist(self.entities)

        o = player.collisionlist(self.entities)
        o2 = player.collisionlistsword(self.entities)
        if o2:
#	    print ("%d" % (o.platform))
	    if swordplay != 0:
		print ("--------SWORDPLAY")
		# NOTE : sword collision has larger width and height values
		#if o2:
                print ("---------HIT")
		o2.hit()#hitpoints -= 1
        	#if o2.hitpoints <= 0:
            	#self.entities.remove(o2)
	    	o2.remove(self.entities)
		#return 
	    ### JUMP elif o:
	elif o:
	    o.dofood(player) 
	    o.doplatform(player,level) 
            player.bounceback(level)
            o.decreasehpinplayer(player, level)
	    o.remove(self.entities)###JUMP
	   ###o2.remove(self.entities)
 
    def collisionplayer(self,mouse,player):
        return mouse.collisionplayer(player)

    def domouse(self,game):
        # Collide mouse with player

        p = game.domouseonplayer(self)
	if p:
            print("mouse click on player 1")
            foo = game.leftbuttonpressed(game.player)
            if foo:
                print("mouse click on player 2")
                return
            
        # Collide mouse with entities
        o = None
        o = game.collisionlistonmouse(self.entities)
        if o:
            foo = game.leftbuttonpressed(o)
#            print foo
            if foo:
                game.screen.scr.blit(game.font.render(foo, 16, (255,255,255)), (20,300))
#                print foo
            else:
                game.screen.scr.blit(game.font.render(o.getname(game.text), 10, (255,255,255)), (game.mouse.x+10,game.mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)
            


    def domouseinventory(self,game):
        # Collide mouse with player
        p = game.domouseonplayer(self)#game.mouse.collisionplayer(game)
        if p:
            footext = game.mouse.leftbuttonpressedwithinventoryitem(game.player,game)
            if footext and footext != "":
                return footext 

        # Collide mouse with entities
        o = None
        o = game.collisionlistonmouse(self.entities)
        if o and game.inventoryitem:
            footext = game.mouse.leftbuttonpressedwithinventoryitem(o,game)#.text,game.inventoryitem)
            if footext and footext != "":
                return footext 

        if not o and game.mouse.press(0):
            return 1

        return None
#             if foo:
#                 screen.scr.blit(font.render(foo, 16, (255,255,255)), (10,10))
# #                print foo
#             else:
#                 screen.scr.blit(font.render(o.getname(text), 10, (0,0,0)), (mouse.x+10,mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)



    def moveup(self, player):
        player.moveupanddirect1()

    def movedown(self, player):
        player.movedownanddirect1()

    def moveleft(self, player):
        player.moveleftanddirect1()

    def moveright(self, player):
        player.moverightanddirect1()


######## COLLISION CODE

    def collisionlistbomb(self,bomb,list):
#         for i in range(0,list.length):
#             o = None
#             o = list.getlistobject(o)

        for o in list.list:
            if o and o.x +12>= bomb.x - bomb.w and o.x <= bomb.x + bomb.w +12and o.y+12 >= bomb.y - bomb.h and o.y <= bomb.y + bomb.h +12:
                return o
        return None


    def collisionexits(self,player,roommanager):
        o = player.collisionlist(self.exits)

        if o:

            print 'foo x=%d,y=%d px=%d py=%d' % (o.x,o.y,player.x,player.y)

            o.room.loadroom()
            roommanager.room = o.room
            player.warp(o.newx,o.newy)
            return 1
        return None

    def collisionboxes(self,player):
        o = player.collisionlist(self.boxes)
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def collisiontriboxes1(self,player):
        o = player.collisionlisttri1(self.triboxes1)
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def collisiontriboxes2(self,player):
        o = player.collisionlisttri2(self.triboxes2)
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def collisiontriboxes3(self,player):
        o = player.collisionlisttri3(self.triboxes3)
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def collisiontriboxes4(self,player):
        o = player.collisionlisttri4(self.triboxes4)
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def collisionandremoveenemieswithbomb(self, bomb):
        o = self.collisionlistbomb(bomb,self.entities)
        if o:
            o.hit()
            o.remove(self.entities)
            self.entities.remove(o)
            
    def summonskeletonunderplayercommand(self,x,y):
        self.addenemy(Skeletonunderplayercommand(x,y,50,50))


    def summonskeleton(self,x,y):
        self.addenemy(Skeleton2(x,y,50,50))

    def removeallenemies(self):
        self.entities = List()
            
    def removeallentities(self):
        self.entities = List()



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from list import *
from box import *
from exitbox import *
from ooze import *
from ent import *
from tree import *
from tree2 import *
from tree3 import *
from movingwallnorth import *
from movingwallsouth import *
from movingwallwest import *
from movingwalleast import *
from treestone import *
from entstone import *
from bat import *
from skeleton import *
from skeleton2 import *
from skeletonunderplayercommand import *
from dragon import *
from dracolich import *
from room import *
from utility import *

from entityfactory import *

import inspect

class Roomroomman(Room):
    ""
    def __init__(self, roomman):
        Room.__init__(self)
        self.initroom()
        self.entityfactory = None
	self.roomman = roomman

    # FIXME
    def addfactory(self,factory):
        frame = inspect.currentframe()
        try:
            frame != None
        finally:
            factory.add(self)

    def loadroom(self,roommanager):
         roommanager.loadroom(self)

    def updatelist(self,list):
        for el in list.list:
            if el:
                el.update(self)

    def addbox(self,x,y,w,h):
        self.boxes.add(Box(x,y,w,h))

    def addexit(self,x,y,w,h,roomid,newx,newy,room):
         self.exits.add(Exitbox(x,y,w,h,roomid,newx,newy,room))

    def addentitythroughfactory(self,room):
        1#FIXME

    def addentity(self,entity):
        if entity:
            self.entities.add(entity)

    def addenemy(self,enemy):
        self.addentity(enemy)

    def addsprite(self,sprite):
        self.addentity(sprite)

    def loadwalls(self):
        1

    def initroom(self):
        self.totalboxes = 0
        self.boxes = List()
        self.totalexits = 0
        self.exits = List()
        self.background = None
        self.entities = List()
        self.idcounter = 0
        self.night = 0
        self.loadwalls()
	

    def draw(self,screen):
        screen.scr.blit(self.background, (0, 0))
        screen.draw(self.entities)

#    def auxdraw(self):
#	self.auxdraw(self.)
#        screen.scr.blit(self.background, (0, 0))
#        screen.draw(self.entities)

    def update(self,player,level,swordplay):#unsused level
        self.updatelist(self.entities)

        o = player.collisionlist(self.entities)
        if o:
#	    print ("%d" % (o.platform))
	    if swordplay != 0:
		print ("--------SWORDPLAY")
		o.hitpoints -= 1
        	if o.hitpoints <= 0:
            	    self.entities.remove(o)    
	    else:
	        o.dofood(player) 
	        o.doplatform(player,level) 
                player.bounceback(level)
                o.decreasehpinplayer(player, level)
	    o.remove(self.entities)
 
    def collisionplayer(self,mouse,player):
        mouse.collisionplayer(player)

    def domouse(self,game):
        # Collide mouse with player

        p = game.domouseonplayer(self)
        if p:
            foo = game.leftbuttonpressed(game.player)
            if foo:
                return
            
        # Collide mouse with entities
        o = None
        o = game.collisionlistonmouse(self.entities)
        if o:
            foo = game.leftbuttonpressed(o)
#            print foo
            if foo:
                game.screen.scr.blit(game.font.render(foo, 16, (255,255,255)), (10,10))
#                print foo
            else:
                game.screen.scr.blit(game.font.render(o.getname(game.text), 10, (0,0,0)), (game.mouse.x+10,game.mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)
            


    def domouseinventory(self,game):#,screen,mouse,font,text,item,player):
        # Collide mouse with player
        p = game.domouseonplayer(self)#game.mouse.collisionplayer(game)
        if p:
            footext3 = game.mouse.leftbuttonpressedwithinventoryitem(game.player,game)
            if footext3 and footext3 != "":
                return footext3 

        # Collide mouse with entities
        o = None
        o = game.collisionlistonmouse(self.entities)
        if o and game.inventoryitem:
            footext = game.mouse.leftbuttonpressedwithinventoryitem(o,game)#.text,game.inventoryitem)
	    print "footext=>" % footext
            if footext and footext != "":
                return footext

        if not o and game.mouse.press(0):
            return 1

        return None
#             if foo:
#                 screen.scr.blit(font.render(foo, 16, (255,255,255)), (10,10))
# #                print foo
#             else:
#                 screen.scr.blit(font.render(o.getname(text), 10, (0,0,0)), (mouse.x+10,mouse.y))
#            mouse.middlebuttonpressed(o,text)
#            mouse.rightbuttonpressed(o,text)



    def moveup(self, player):
        player.moveupanddirect1()

    def movedown(self, player):
        player.movedownanddirect1()

    def moveleft(self, player):
        player.moveleftanddirect1()

    def moveright(self, player):
        player.moverightanddirect1()


######## COLLISION CODE

    def collisionlistbomb(self,bomb,list):
#         for i in range(0,list.length):
#             o = None
#             o = list.getlistobject(o)

        for o in list.list:
            if o and o.x >= bomb.x - bomb.w and o.x <= bomb.x + bomb.w and o.y >= bomb.y - bomb.h and o.y <= bomb.y + bomb.h:
                return o
        return None


    def collisionexits(self,player,roommanager):
        o = player.collisionlist(self.exits)

        if o:

            print 'foo x=%d,y=%d px=%d py=%d' % (o.x,o.y,player.x,player.y)

            o.room.loadroom()
            roommanager.room = o.room
            player.warp(o.newx,o.newy)
            return 1
        return None

    def collisionboxes(self,player):
        o = player.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None


    def collisionandremoveenemieswithbomb(self, bomb):
        o = self.collisionlistbomb(bomb,self.entities)
        if o:
            o.hit()
            o.remove(self.entities)
            self.entities.remove(o)
            
    def summonskeletonunderplayercommand(self,x,y):
        self.addenemy(Skeletonunderplayercommand(x,y,50,50))


    def summonskeleton(self,x,y):
        self.addenemy(Skeleton2(x,y,50,50))

    def removeallenemies(self):
        self.entities = List()
            
    def removeallentities(self):
        self.entities = List()



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

class Screen:
    def __init__(self):
        self.scr = pygame.display.set_mode((640, 480))

    def draw(self, list):
        for o in list.list:
            o.draw(self)

    def drawonmap(self, maproom):
        for o in maproom.entities.list:
            o.drawonmap(self, maproom)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Scrollinvisibility(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('scroll1.bmp',255,255,255)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber
	self.flag = None 

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a scroll of invisibility "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):
        string = "You have a scroll of invisibility "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

	if self.flag:
		return None 

        if Utilities().readandfindstring(string):
            ### print "+++ Scroll of invisibility registered"
	    self.flag = 1
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getscrollinvisibilityname()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemshadowblade import *
from entityfactory import *
from food import *

class Shadowblade(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemshadowblade())
        self.addimage('shadowblade11.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getshadowbladename()

#    def gettalk(self):
#        talksystem.gettalk(self)
    def update(self,room):
	1

####### other methods
    def draw(self,screen):
        screen.scr.blit(self.images[0], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the shadowblade."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemshieldmaiden import *

class Shieldmaiden(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemshieldmaiden())
        self.addimage('shieldmaiden1.1.bmp',0,0,0)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getshieldmaidenname()

#    def gettalk(self):
#        talksystem.gettalk(self)


####### other methods
    def draw(self,screen):
            screen.scr.blit(self.images[0], (self.x, self.y))

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo


    def update(self,room):
        1

    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the myconid."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *
import random

class Skeleton2(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h)

        self.addimage('skeleton1.bmp',0,0,0)
        self.addimage('skeleton2.bmp',0,0,0)
        self.addimage('skeleton3.bmp',0,0,0)
        self.addimage('skeleton4.bmp',0,0,0)
        self.addimage('skeleton5.bmp',0,0,0)

        self.counter = 0
        self.direction = "south"

    def getname(self,text):
        return text.getskeletonname()

    def draw(self,screen):
        self.counter += 1

        if self.counter > 60:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x, self.y))
        else:
            screen.scr.blit(self.images[0], (self.x, self.y))

    def update(self,level):

        r = randint(0,100)

        if r < 1:

            r2 = randint(0,3)
            if r2 == 0:
                self.direction = "north"
            if r2 == 1:
                self.direction = "south"
            if r2 == 2:
                self.direction = "west"
            if r2 == 3:
                self.direction = "east"


        if self.collisionlist(self,level.entities) != self or self.collisionlist(self,level.exits) or self.collisionlist(self,level.boxes):
            # FIXME colliision with self
            
#            print "entity bounce back"
            self.bounceback()
            self.bounceback()
            self.bounceback()
            r3 = randint(0,3)
            if r3 == 0:
                self.direction = "north"
            if r3 == 1:
                self.direction = "south"
            if r3 == 2:
                self.direction = "west"
            if r3 == 3:
                self.direction = "east"


        if self.direction == "north":
            self.y -= 1
        if self.direction == "south":
            self.y += 1
        if self.direction == "west":
            self.x -= 1
        if self.direction == "east":
            self.x += 1
        
    def bounceback(self):
        if self.direction == "north":
            self.y += 1
            #self.movedown()
        elif self.direction == "south":
            self.y -= 1
            #self.moveup()
        elif self.direction == "west":
            self.x += 1
            #self.moveright()
        elif self.direction == "east":
            self.x -= 1
            #self.moveleft()

    def isskeleton(self):
        return 1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Skeleton(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h)

        self.addimage('skeleton1.bmp',0,0,0)
        self.addimage('skeleton2.bmp',0,0,0)
        self.addimage('skeleton3.bmp',0,0,0)
        self.addimage('skeleton4.bmp',0,0,0)
        self.addimage('skeleton5.bmp',0,0,0)

        self.counter = 0

    def getname(self,text):
        return text.getskeletonname()

    def draw(self,screen):
        self.counter += 1

        if self.counter > 60:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x, self.y))
        else:
            screen.scr.blit(self.images[0], (self.x, self.y))


    def update(self,level):

        r = randint(0,3)
        if r == 0:
            self.direction = "south"
            self.y += 3
        if r == 1:
            self.direction = "north"
            self.y -= 3
        if r == 2:
            self.direction = "east"
            self.x += 3
        if r == 3:
            self.direction = "west"
            self.x -= 3


#FIXME
    def bounceback(self):

        print "+++ bounce back"
#        print self.direction

        if self.direction == "north":
            #print self.y
            self.y += 5
            #self.movedown()
        elif self.direction == "south":
            self.y -= 5
            #self.moveup()
        elif self.direction == "west":
            self.x += 5
            #self.moveright()
        elif self.direction == "east":
            self.x -= 5
            #self.moveleft()

    def isskeleton(self):
        return 1

    def isplayerskeleton(self):
        return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *


# Player's skeleton
class Skeletonunderplayercommand(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h)

        self.addimage('skeleton1.bmp',0,0,0)
        self.addimage('skeleton2.bmp',0,0,0)
        self.addimage('skeleton3.bmp',0,0,0)
        self.addimage('skeleton4.bmp',0,0,0)
        self.addimage('skeleton5.bmp',0,0,0)

        self.counter = 0

    def getname(self,text):
        return text.getskeletonofplayername()

    def draw(self,screen):
        self.counter += 1

        if self.counter > 60:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[3], (self.x, self.y))
        elif self.counter < 50:
            screen.scr.blit(self.images[4], (self.x, self.y))
        else:
            screen.scr.blit(self.images[0], (self.x, self.y))


    def update(self,level):

        # seek and destroy
        
        e = level.entities.getwithindex(0)#FIXME 0

        if e and not e.isplayerskeleton():
            if self.x <= e.x:
                self.x += 1
            if self.x >= e.x:
                self.x -= 1
            if self.y <= e.y:
                self.y += 1
            if self.y >= e.y:
                self.y -= 1
        
            o = None
            o = self.collisionlist(e,level.entities)

            if o and e != o:
                o.hit()
                e.hit()
                e.remove(level.entities)
                o.remove(level.entities)
                #FIXME level.entities.remove(e)
                return

#    def hit(self):
#            print "hit on your skeleton" 
#            self.hitpoints -= self.decreasehp

#     def remove(self,list):
#         if self.hitpoints <= 0:
#             list.remove(self)

#FIXME
    def bounceback(self):

        print "+++ bounce back"
#        print self.direction

        if self.direction == "north":
            #print self.y
            self.y += 5
            #self.movedown()
        elif self.direction == "south":
            self.y -= 5
            #self.moveup()
        elif self.direction == "west":
            self.x += 5
            #self.moveright()
        elif self.direction == "east":
            self.x -= 5
            #self.moveleft()

    def isplayerskeleton(self):
        return 1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *


class Spellbookdracolich(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('spellbookdracolich1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber

    def update(self,level):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a dracolich's spellbook "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
	    print "456"
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readspellbook(self, list):
        string = "You have a dracolich's spellbook "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            ## print "+++ spellbook registered"
            if list:
                list.remove(self)
            return 1

        return None

    def readdestroyspellbook(self, list):
        string = "You have destroyed the dracolich's spellbook"
        string += "\n"

        if Utilities().readandfindstring(string):
	    print "000"
            print "+++ spellbook destruction 1 registered"
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getspellbookdracolichname()

    def use(self, e, game):
	print 'You used the dracolich\'s spellbook on %s' % e
	if e:
	    e.usedracolichspellbookonentity(game)

	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *


class Spellbooknootie(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('spellbooknootie1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber

    def update(self,level):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a Nootie's spellbook "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readspellbook(self, list):
        string = "You have a Nootie's spellbook "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        if Utilities().readandfindstring(string):
            print "+++ spellbook Nootie registered"
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getspellbooknootiename()

    def use(self, e, game):
	print 'You used the dracolich\'s spellbook on %s' % e
	if e:
	    e.usedracolichspellbookonentity(game)

	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *


class Spellschooseritem(object):
    def __init__(self,imagefilename):
        self.image = pygame.image.load(imagefilename).convert()
        self.image.set_colorkey((0,0,0))#FIXME rgb transdparency

    def draw(self,screen,x,y):
        screen.scr.blit(self.image, (x, y))

    def addtolist(self,list):
        list.addobject(self)

### NOTE There s no fallthrough for item usage


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *
from list import *
from inventorybomb import *

class SpellsChooser(object):
    def __init__(self):
        self.background = pygame.image.load('bg_inventory.bmp').convert()
        self.list = List()

        self.rectimage = pygame.image.load('rect2.bmp').convert()
        self.rectimage.set_colorkey((0,0,0))
        self.selectioncounter = 0 

    def draw(self,screen):

        screen.scr.blit(self.background, (0, 0))

        position = pygame.mouse.get_pos()
        x = position[0]
        y = position[1]
        self.drawrect(screen,x-100,y-10)

        for i in range(0,self.list.length):
            o = self.list.getwithindex(i)
# pass by value FIXME
#             o = None
#             o = self.list.getlistobject(o)
            if o:
                o.draw(screen,20,20*i)



    def drawrect(self,screen,x,y):
        screen.scr.blit(self.rectimage, (x, y))


    def moveleft(self):
        if self.selectioncounter > 0:
            self.selectioncounter -= 1

    def moveright(self):
        if self.selectioncounter < 8:
            self.selectioncounter += 1

    def getitem(self,o):
	#        for i in range(0,self.selectioncounter):
	#            o = None
	#            o = self.list.getlistobject(o)
        o = self.list.getwithindex(self.selectioncounter) 
        if o:
            return o

        return None

    def getitemwithmouse(self,o,mouse):
        position = pygame.mouse.get_pos()
        x = position[0]
        y = position[1]
	print "x=%d" % x
	print "y=%d" % y
	i = 1 
	previ = 0
	for i in range(1,8):
	    if y <= 20*i and y >= 20*previ and x < 200:
                o = self.list.getwithindex(i-1) 
                if o:
                    return o
	    previ = i
        return None

    def additem(self,o):
        self.list.addobject(o)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from random import *
from spellschooseritem import *

class Spellschooserspellbookdracolichsummonskeleton(Spellschooseritem):
    def __init__(self):
        Spellschooseritem.__init__(self, "spellschooserspellbookdracolich1.bmp")

    def getname(self):
        return "Dracolich's spell"

    def cast(self, game):
        x = randint(0,500)
        y = randint(0,300)
        game.player.manapoints -= game.player.decreasemanapoints
        if game.player.manapoints > 0:
            game.level.roommanager.room.summonskeletonunderplayercommand(x,y)
	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
from pygame.locals import *
from random import *
from spellschooseritem import *

class Spellschooserspellbooknootieentangle(Spellschooseritem):
    def __init__(self):
        Spellschooseritem.__init__(self, "spellschooserspellbooknootie1.bmp")

    def getname(self):
        return "Nootie's spell"

    def cast(self, game):
        x = randint(0,500)
        y = randint(0,300)
        game.player.manapoints -= game.player.decreasemanapoints
        if game.player.manapoints > 0:
            for e in game.level.roommanager.room.entities.list:
		e.entangled = 1
	

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from random import *
from entity import *
class Sprite(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        
    def update(self,level):
        1

    def bounceback(self):
        1

    def remove(self,list):
        1

    def bounceback(self):
        1

    def hit(self):
        1


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Sword1blue(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('sword1blue.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber
	self.flag = None 

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    #FIXME copy-paste in dracolich.py
    def remove(self,list):
        string = "You have a sword "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

        s = ""

        if Utilities().readandfindstring(string):
            list.remove(self)
            return None
        
        f = open("./workfile",'r')
        for line in f:
            s += line

        f = open("./workfile",'w')
        
        f.write(s)
        f.write(string)
        f.write("\n")

        return 1
 
    #FIXME copy-paste in dracolich.py readboss
    def readkeys(self, list):
        string = "You have a sword "
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string += "\n"

	if self.flag:
		return None 
        if Utilities().readandfindstring(string):
            ### print "+++ Seraphim sword (blue) registered"
	    self.flag = 1
            if list:
                list.remove(self)
            return 1

        return None

    def getname(self,text):
        return text.getsword1bluename()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphangel import *

class Talksystemangel(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphangel()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphassassin import *

class Talksystemassassin(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphassassin()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphassassinqueen import *

class Talksystemassassinqueen(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphassassinqueen()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphbirdsparrow import *

class Talksystembirdsparrow(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphbirdsparrow()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphblimp import *

class Talksystemblimp(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphblimp()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphcandleflame1 import *

class Talksystemcandleflame1(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphcandleflame1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphcandleflame2 import *

class Talksystemcandleflame2(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphcandleflame2()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphchaosknight1 import *

class Talksystemchaosknight1(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphchaosknight1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphcherubstatue1 import *

class Talksystemcherubstatue1(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphcherubstatue1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphdemon1 import *

class Talksystemdemon1(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphdemon1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphdjinnofnootie import *

class Talksystemdjinnofnootie(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphdjinnofnootie()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphearthweird import *

class Talksystemearthweird(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphearthweird()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphghoststory import *

class Talksystemghoststory(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphghoststory()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphgoblinguardian import *

class Talksystemgoblinguardian(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphgoblinguardian()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphhermit import *

class Talksystemhermit(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphhermit()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphhobgoblinswordsman1 import *

class Talksystemhobgoblinswordsman1(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphhobgoblinswordsman1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphhoundarchon import *

class Talksystemhoundarchon(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphhoundarchon()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphknightgrey import *

class Talksystemknightgrey(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphknightgrey()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphkoboldmage import *

class Talksystemkoboldmage(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphkoboldmage()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphmyconid import *

class Talksystemmyconid(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphmyconid()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphnutter2 import *

class Talksystemnutter2(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphnutter2()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphnutter3 import *

class Talksystemnutter3(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphnutter3()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphnutter4 import *

class Talksystemnutter4(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphnutter4()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphnutternootie import *

class Talksystemnutternootie(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphnutternootie()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphnutter import *

class Talksystemnutter(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphnutter()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphorcblue1 import *

class Talksystemkoboldmage(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphorcblue1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphorcguardian import *

class Talksystemorcguardian(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphorcguardian()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphorcpaladin import *

class Talksystemorcpaladin(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphorcpaladin()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphorcswordsmanblue import *

class Talksystemorcswordsmanblue(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphorcswordsmanblue()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphorcvillagewarrior1 import *

class Talksystemorcvillagewarrior1(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphorcvillagewarrior1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Talksystem(object):
    def __init__(self):#pass
        1

    def gettalk(self,text):
        return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphshieldmaiden import *

class Talksystemshieldmaiden(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphshieldmaiden()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphtrollblack import *

class Talksystemtrollblack(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphtrollblack()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphvillageorc1 import *

class Talksystemvillageorc1(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphvillageorc1()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphvillageorc2 import *

class Talksystemvillageorc2(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphvillageorc2()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphvillageorc3 import *

class Talksystemvillageorc3(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphvillageorc3()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphwaterdevilfemale import *

class Talksystemwaterdevilfemale(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphwaterdevilfemale()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from talksystem import *
from graphwaterdevil import *

class Talksystemwaterdevil(Talksystem):
    def __init__(self):
        Talksystem.__init__(self)
        self.graph = Graphwaterdevil()
        
    def gettalk(self,text):
        return self.graph.get(text)
        

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from text import *

class Textdutch(Text):
    
    def getname(self,o):
        return o.getnametext(self)

    def getbatname(self):
        return "Vleermuis"

    def getmyconidname(self):
        return "Paddestoelmannetje"

    def getentname(self):
        return "Boomman"

    def getskeletonname(self):
        return "Skelet"

    def gettreename(self):
        return "Boom"

    def getearthweirdname(self):
        return "Aardgeest"

    def getkeyname(self):
        return "Sleutel"

    def getdracolichname(self):
        return "Draak liche"

    def getspellbookdracolichname(self):
        return "Draak liche toverboek"

    def getskeletonofplayername(self):
        return "Skelet onder jouw commando"

    def getkoboldmagename(self):
        return "Kobold magier"

    ############# MYCONID

    def getmyconid1(self):
        return "De aarde is lichter hier."

    def getmyconid2(self):
        return "Ik leer je toveren."

    ############# EARH WEIRD

    def getearthweird1(self):
        return "Hallo."

    def getearthweird2(self):
        return "IK ben de aarde meester."

    ############# KOBOLD MAGE

    def getkoboldmage1(self):
        return "Kurtulmak weze geprezen!"

    def getkoboldmage2(self):
        return "Breng me een duister geheim."

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from text import *

class Textenglish(Text):


    def getname(self,o):
        return o.getnametext(self)

    def getnullname(self):
        return "..."
    
    def getsword1bluename(self):
        return "Seraphim sword"

    def getcandlename(self):
        return "Candle"
    
    def getscrollinvisibilityname(self):
        return "Scroll of invisibility"
    
    def gethermitname(self):
        return "Hermit"
    
    def gettrollblackname(self):
        return "Black troll"

    def getknightgreyname(self):
        return "Grey Knight"

    def getdjinnofnootiename(self):
        return "Djinni of Nootie"

    def getorcguardianname(self):
        return "Orc Guardian"

    def getassassinname(self):
        return "Rogue Assassin"

    def getassassinqueenname(self):
        return "Princess - Assassin Queen"

    def getgoblinguardianname(self):
        return "Goblin Guardian"

    def getoozebigname(self):
        return "Big blue ooze"

    def gethoundarchonname(self):
        return "Hound archon"

    def getknightdarkname(self):
        return "Dark knight"

    def getmoneyname(self):
        return "Money"

    def getfoodname(self):
        return "Food"

    def getchestname(self):
        return "Chest"

    def getunicornstatuename(self):
        return "Unicorn statue"

    def getringbluename(self):
        return "Blue ring"
    
    def getcherubstatuename(self):
        return "Cherub"
    
    def getbatname(self):
        return "Bat"
    
    def getcandleflame1name(self):
        return "Flame angel"

    def getmyconidbluename(self):
        return "Blue myconid"
    
    def getchaosknight1name(self):
        return "Dark Warrior"

    def getshadowbladename(self):
        return "Shadowblade"

    def getbirdsparrowname(self):
        return "Blue sparrow"

    def getnuttername(self):
        return "Nutter"

    def getnutter2name(self):
        return "Nutter"

    def getnutter3name(self):
        return "Nutter"
   
    def getnutter4name(self):
        return "Nutter"

    def getnutternootiename(self):
        return "Nutter Nootie"

    def getmyconidname(self):
        return "Myconid"
    
    def getentstonename(self):
        return "Stone Ent"

    def getblimpname(self):
        return "Blimp"

    def getghoststoryname(self):
        return "Diligent Ghost"

    def getshieldmaidenname(self):
        return "Elf"

    def getentname(self):
        return "Ent"

    def getskeletonname(self):
        return "Skeleton"

    def gettreename(self):
        return "Tree"

    def gettoadstoolname(self):
        return "Toadstool"

    def getblueorcname(self):
        return "Blue Orc"
    
    def gethobgoblinswordsmanname(self):
        return "Hobgoblin Swordsman"
    
    def getvillageorcmagename(self):
        return "Blue Orc Mage"

    def getorcpaladinname(self):
        return "Orc Paladin"
    
    def getorcswordsmanbluename(self):
        return "Orc swordsman"

    def getwaterdevilname(self):
        return "Water devil"

    def getwaterdevilfemalename(self):
        return "Water devil female"
    
    def getensorcelledtreename(self):
        return "Enscorcelled tree"

    def getangelname(self):
        return "Angel"
    
    def getdemon1name(self):
        return "Demon fighter"
    
    def getorchutname(self):
        return "Orc hut"
    
    def getearthweirdname(self):
        return "Earth weird"

    def getkeyname(self):
        return "Key"

    def getkey2name(self):
        return "Blue key"

    def getkey3name(self):
        return "Golden key"

    def getdracolichname(self):
        return "Dracolich"

    def getspellbookdracolichname(self):
        return "Dracolich's spellbook"

    def getspellbooknootiename(self):
        return "Nootie's spellbook"

    def getskeletonofplayername(self):
        return "Skeleton under your command"

    def getkoboldmagename(self):
        return "Kobold mage"

    ############# DJINN of NOOTIE

    def getdjinnofnootie1(self):
        return "Hello there."

    def getdjinnofnootie2(self):
        return "Bring a nut, deserve my gut!"

    ############# NUTTER 

    def getnutter1(self):
        return "Hello. I am Stawie."

    def getnutter2(self):
        return "I am a disciple in magic. Nootie is my master."

    def getnutter3(self):
        return "He lives further north from here, in our little village."

    def getnutter4(self):
        return "He is hard-hearing..so be patient with him."

    ############# NUTTER2 

    def getnutter21(self):
        return "We are the Nut People."

    def getnutter22(self):
        return "Green and Brown Magic flows through us."

    ############# NUTTER3 

    def getnutter31(self):
        return "Hi, I am Nookie."

    def getnutter32(self):
        return "Once I encountered a Unicorn."

    def getnutter33(self):
        return "It was a fabulous animal."

    def getnutter34(self):
        return "He should be still out there in the wilds."

    ############# NUTTER4

    def getnutter41(self):
        return 'This village is but temporary. It is not well guarded.'

    def getnutter42(self):
        return "Ask the wizard."

    ############# NUTTER NOOTIE 

    def getnutternootie1(self):
        return "Que ?"

    def getnutternootie2(self):
        return "Excellent!"

    def getnutternootie3(self):
        return "Yes taskmaster..."

    def getnutternootie4(self):
        return "This feels heavy."


    ############# SPARROW 

    def getbirdsparrow1(self):
        return "There is a hole under the black tree."

    def getbirdsparrow2(self):
        return "All you have to do is remove the tree...haha!"

    #############  TROLL BLACK

    def gettrollblack1(self):
        return "..gnuvy.."

    def gettrollblack2(self):
        return "*groink*"

    #############  GREY KNIGHT 

    def getknightgrey1(self):
        return "For Wrath and Glory !"

    def getknightgrey2(self):
        return "Fight, cretin !"

    ############# ORC GUARDIAN 

    def getorcguardian1(self):
        return "Yes taskmaster..."

    def getorcguardian2(self):
        return "..."

    ############# GOBLIN GUARDIAN
 
    def getgoblinguardian1(self):
        return "Brotherhood.."

    def getgoblinguardian2(self):
        return "Yes taskmaster..."

    ############# ROGUE ASSASSIN 

    def getassassin1(self):
        return "Welcome..."

    def getassassin2(self):
        return "I am no magaician like you."

    ############# ASSASSIN QUEEN - PRINCESS 

    def getassassinqueen1(self):
        return "Welcome."

    def getassassinqueen2(self):
        return "Let me contact Celestia for you..."


    ############# HERMIT 

    def gethermit1(self):
        return "Use the Seraphim ring on walls."

    def gethermit2(self):
        return "You will be able to walk through."

    ############# CANDLEFLAME 2

    def getcandleflame21(self):
        return "This dungeon was a castle built on water."

    def getcandleflame22(self):
        return "We are the eternal flame which burns for this dungeon."

    def getcandleflame23(self):
        return "All elven lords of the castle went into these flames."

    def getcandleflame24(self):
        return "They are now one with the fire."

    def getcandleflame25(self):
        return "The fire contrasts the water, thus is our blessing."

    ############# CANDLEFLAME 1

    def getcandleflame11(self):
        return "We are fiery angels."

    def getcandleflame12(self):
        return "We are the Red Seraphim."

    def getcandleflame13(self):
        return "Wander into the flames if you must."

    def getcandleflame14(self):
        return "You will not be harmed."

    def getcandleflame15(self):
        return "That is our blessing."

    ############# DARK WARRIOR 

    def getchaosknight11(self):
        return "You will face defeat."

    def getchaosknight12(self):
        return "I will show no mercy."

    ############# GHOSTSTORY 

    def getghoststory1(self):
        return "Hello. I am a Spectre of Old."

    def getghoststory2(self):
        return "Your destiny is unknown to me."

    ############# MYCONID
    ############# BLIMP 

    def getblimp1(self):
        return "I am sailing ..."

    def getblimp2(self):
        return "I am sailing!"

    ############# MYCONID

    def getmyconid1(self):
        return "The earth is bright here."

    def getmyconid2(self):
        return "I'll learn you some magic."

    ############# EARTH WEIRD

    def getearthweird1(self):
        return "Hello."

    def getearthweird2(self):
        return "I'm an earth master."

    ############# KOBOLD MAGE

    def getkoboldmage1(self):
        return "Praise to Kurtulmak!"

    def getkoboldmage2(self):
        return "Bring me the secret of the dark."


    ############# ORCBLUE1 

    def getorcblue11(self):
        return "This is Staw .. Orc Village."

    def getorcblue12(self):
        return "We do not have many guests here."

    ############# VILLAGE ORC 2 

    def getvillageorc21(self):
        return "This is Staw .. Orc Village."

    def getvillageorc22(self):
        return "We do not have many guests here."

    ############# ORC VILLAGE 3 (not MAGE) 

    def getvillageorc31(self):
        return "I do not want to talk to you."

    def getvillageorc32(self):
        return "Go Away."

    ############# ORC VILLAGE 2 (MAGE) 

    def getvillageorc11(self):
        return "Kobold magi .. torture .. twilight .."

    def getvillageorc12(self):
        return "Do not travel to the north .. "

    ############# WATER DEVIL FEMALE 

    def getwaterdevilfemale1(self):
        return "Take the Elven sword."
    def getwaterdevilfemale2(self):
        return "It has a red Seraphim in it which guides you through the battle"
    def getwaterdevilfemale3(self):
        return "This water fortress was built by high elves"
    def getwaterdevilfemale4(self):
        return "Evil cursed the landlords and they are now hither"
    def getwaterdevilfemale5(self):
        return "Witch elves destroyed the keep"
    def getwaterdevilfemale6(self):
        return "I am the last elven maiden left"
    def getwaterdevilfemale7(self):
        return "I was condemned into this form"
    def getwaterdevilfemale8(self):
        return "My hope is with you."
    def getwaterdevilfemale9(self):
        return "Please defeat the evil which overtook us."
        return "You are our last hope."
    ############# WATER DEVIL FEMALE 

    def getwaterdevil1(self):
        return ".blurbs..."

    def getwaterdevil2(self):
        return "...splat.."

    ############# ORC SWORDSMAN

    def getorcswordsmanblue1(self):
        return "We were elves once."

    def getorcswordsmanblue2(self):
        return "But darkness took us..."

    ############# ORC WARRIOR VILLAGE

    def getorcpaladin1(self):
        return "I defend the good cause."

    def getorcpaladin2(self):
        return "May the gods be with you..."

    ############ SHIELD MAIDEN
    def getshieldmaiden1(self):
        return "These mountains connect the Elf Tower with the west."
    def getshieldmaiden2(self):
        return "The elves have gone now."
    def getshieldmaiden3(self):
        return "They left the tower ages ago."

    ############ HOBGOBLIN SWORDSMAN 1   
    def gethobgoblinswordsman1(self):
        return "..."
    def gethobgoblinswordsman2(self):
        return "..."
    
    ############# HOUND ARCHON 

    def gethoundarchon1(self):
        return "Red angels do not thrive in water."

    def gethoundarchon2(self):
        return "Do not venture too deep in the water.."

    ############# ANGEL 

    def getangel1(self):
        return "Try to find a good person and share with him."

    def getangel2(self):
        return "Celestia is watching you."

    ############# DEMON1 

    def getdemon11(self):
        return "Hissssss!"

    def getdemon12(self):
        return "Darkness will prevail ...!"

    def getangelusedspellbook(self):
        return "The book disappears in the angel's hands!"

    ############# CHERUBSTATUE1 

    def getcherubstatue11(self):
        return "May god bless you."

    def getcherubstatue12(self):
        return "Take the ring of the Seraphim next to me."

    def getcherubstatue13(self):
        return "May it aid you upon your quest."

    def getcherubstatue14(self):
        return "Watch out for the dark side of the lands."

   ############## DEFAULTS

    def getnothinghappens(self):
	return "Nothing happens."

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


class Text(object):
    pass

#    def getname(self,o):
#        return o.name

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from entity import *

class Toadstool(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('toadstool1.bmp',0,0,0)

#     def draw(self,screen):#FIXME
#         self.imagescounter += 1
#         if self.imagescounter == self.maximages:
#             self.imagescounter = 0     
#         screen.scr.blit(self.images[self.imagescounter], (self.x, self.y))

    def getname(self,text):
        return text.gettoadstoolname()

    def update(self,level):
        1

    def remove(self,list):
        1#list.remove(self)



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Tree2night(Entity):
    def __init__(self,screen,id,x,y,w,h):
        Entity.__init__(self,id,screen,x,y,w,h)
        self.addimage('tree2night.bmp',0,0,0)

    def update(self,level):
        1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from entity import *

class Tree2(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('tree2.bmp',0,0,0)

#     def draw(self,screen):#FIXME
#         self.imagescounter += 1
#         if self.imagescounter == self.maximages:
#             self.imagescounter = 0     
#         screen.scr.blit(self.images[self.imagescounter], (self.x, self.y))

    def getname(self,text):
        return text.gettreename()

    def update(self,level):
        1

    def remove(self,list):
        1#list.remove(self)



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.




# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Tree3(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('tree3.bmp',0,0,0)

    def getname(self,text):
        return text.gettreename()

    def update(self,level):
        1

    def remove(self,list):
        1#list.remove(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Tree4(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('tree4.bmp',0,0,0)

    def getname(self,text):
        return text.gettreename()

    def update(self,level):
        1

    def remove(self,list):
        1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Tree5(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('tree2night.bmp',0,0,0)

    def getname(self,text):
        return text.gettreename()

    def update(self,level):
        1

    def remove(self,list):
        1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Tree6(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('tree6.bmp',0,0,0)

    def getname(self,text):
        return text.gettreename()

    def update(self,level):
        1

    def remove(self,list):
        1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Tree(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('tree1.bmp',0,0,0)

    def getname(self,text):
        return text.gettreename()


    def update(self,level):
        1

    def remove(self,list):
        1#list.remove(self)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Treestone(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('treestone1.bmp',0,0,0)

    def getname(self,text):
        return text.gettreename()

    def update(self,level):
        1

    def remove(self,list):
        1

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemy import *

class Treestonewithcandles(Enemy):
    def __init__(self,x,y,w,h):
        Enemy.__init__(self,x,y,w,h)
        self.addimage('treestonewithcandles1.bmp',255,255,255)
#        self.addimage('treestonewithcandles3.bmp',255,255,255)
#        self.addimage('treestonewithcandles4.bmp',255,255,255)

    def getname(self,text):
        return text.getensorcelledtreename()

    def update(self,level):
        1

    def remove(self,list):
        1

    def update(self,room):#FIXME all level arg must be room
	1


# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#from bouncer import *
from enemytalking import *
from talksystemtrollblack import *
from entityfactory import *
from food import *

class Trollblack(Enemytalking):#Bouncer):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemtrollblack())
        self.addimage('trollblack1.bmp',255,255,255)
        self.addimage('trollblack2.bmp',255,255,255)
        self.addimage('trollblack3.bmp',255,255,255)
        self.counter = 0

	self.direction = 1 
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.gettrollblackname()

#    def gettalk(self):
#        talksystem.gettalk(self)
#    def update(self,room):
#	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
	if self.entangled:
        	rootsimage = pygame.image.load('entangleroots1.bmp').convert()
        	rootsimage.set_colorkey((0,0,0))
        	screen.scr.blit(rootsimage, (self.x, self.y+self.h-40))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The trollblack drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the trollblack."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room

	if self.entangled:
		return

	ri = randint(0,42)
	if ri == 14:
	    r = randint(1,4)
	    self.direction = r
	o = None
	o = self.collisionboxes()

	if o:
	    r = randint(0,40)
	    if r < 2:
	        self.bounceback(None) 	
        if self.direction == 1:#north
	     self.y -= 1
        elif self.direction == 3:#south
 	     self.y += 1
        elif self.direction == 4:#west
             self.x -= 1
        elif self.direction == 2:#east
	     self.x += 1


    def bounceback(self,level):
        if self.direction == 1:#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == 3:#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == 4:#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == 2:#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	r = randint(1,4)
	self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Unicornstatuelittle(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('unicornstatuelittle1.bmp',255,255,255)

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    def remove(self,list):
   	1
 
    def getname(self,text):
        return text.getunicornstatuename()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os

from utility import *

class Unicornstatue(Entity):
    def __init__(self,x,y,w,h):
        Entity.__init__(self,x,y,w,h)
        self.addimage('unicornstatue1.bmp',255,255,255)

    def update(self,level):
        1

    def deathupdate(self):
        1
        
    def remove(self,list):
   	1
 
    def getname(self,text):
        return text.getunicornstatuename()

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.



class Utilities:
    def readandfindstring(self,string):
        f = open('./workfile', 'r')

        for line in f:
            if line == string:
                return 1
        return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from list import *

class Videocodec:
    def __init__(self, frequency, max, max2, screen):
        self.images = List() 
	self.counter = 0
        self.imagesfrequent = List()
	self.max = max
	self.max2 = max2
	self.frequency = frequency
	self.screen = screen

    def addimage(self,img):
        self.images.addobject(img)

    def addimagefrequent(self,img):
        self.imagesfrequent.addobject(img)
   
    def play(self,game):
	### first display the static image in images
	if self.counter < self.max:
	    ## DISPLAY VIDEO IMG
            self.screen.scr.blit(self.images.list[0], (500,300))
	### second display, after frequency, the images in imagesfrequent
	elif self.counter >= self.frequency:
            self.screen.scr.blit(self.imagesfrequent.list[self.counter % self.frequency], (500,300))
	self.counter += 1
	if self.counter >= self.max2:
	    game.video = None 
	    self.counter = 0
		

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *

class Wallwalk2(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('wallwalk21.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,room):
	if self.counter > 1:
        #image1 = pygame.image.load('wallwalk2.bmp').convert()
        #    game.screen.scr.blit(image1, (self.x, self.y))
	    self.counter -= 1
	else:
	    self.remove(room.entities)
        #1

    def remove(self,list):
	if self.counter == 1:
            list.remove(self)
	    return 1
        return None 
        #string = "You have a yellow ring"
        #string += self.keynumber
        #string += " - dungeon "
        #string += self.dungeonnumber
        #string = "\n"
        #print "foo"

        #if Utilities().readandfindstring(string):
        #    print "You walk through the wall with the yellow ring"
        #    list.remove(self)
        #    return 1
        
        #return None
	1


    def useyellowring(self,game):
        string = "You have destroyed a wall"
        string += "\n"
        print "BAZ"
	self.counter = 22
	self.imagescounter = 0
        self.maximages = 0
	self.images = [] 
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk21.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
        self.addimage('wallwalk22.bmp',0,0,0)
	#self.remove(game.level.roommanager.room.entities)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *

class Wallwalk(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('wallwalk1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,room):
	if self.counter > 1:
        #image1 = pygame.image.load('wallwalk2.bmp').convert()
        #    game.screen.scr.blit(image1, (self.x, self.y))
	    self.counter -= 1
	else:
	    self.remove(room.entities)
        #1

    def remove(self,list):
	if self.counter == 1:
            list.remove(self)
	    return 1
        return None 
        #string = "You have a yellow ring"
        #string += self.keynumber
        #string += " - dungeon "
        #string += self.dungeonnumber
        #string = "\n"
        #print "foo"

        #if Utilities().readandfindstring(string):
        #    print "You walk through the wall with the yellow ring"
        #    list.remove(self)
        #    return 1
        
        #return None
	1


    def useyellowring(self,game):
        string = "You have destroyed a wall"
        string += "\n"
        print "BAZ"
	self.counter = 22
	self.imagescounter = 0
        self.maximages = 0
	self.images = [] 
        self.addimage('wallwalk2.bmp',0,0,0)
        self.addimage('wallwalk2.bmp',0,0,0)
        self.addimage('wallwalk3.bmp',0,0,0)
        self.addimage('wallwalk3.bmp',0,0,0)
        self.addimage('wallwalk4.bmp',0,0,0)
        self.addimage('wallwalk4.bmp',0,0,0)
        self.addimage('wallwalk5.bmp',0,0,0)
        self.addimage('wallwalk5.bmp',0,0,0)
        self.addimage('wallwalk6.bmp',0,0,0)
        self.addimage('wallwalk6.bmp',0,0,0)
        self.addimage('wallwalk7.bmp',0,0,0)
        self.addimage('wallwalk7.bmp',0,0,0)
        self.addimage('wallwalk8.bmp',0,0,0)
        self.addimage('wallwalk8.bmp',0,0,0)
        self.addimage('wallwalk9.bmp',0,0,0)
        self.addimage('wallwalk9.bmp',0,0,0)
        self.addimage('wallwalk10.bmp',0,0,0)
        self.addimage('wallwalk10.bmp',0,0,0)
        self.addimage('wallwalk11.bmp',0,0,0)
        self.addimage('wallwalk11.bmp',0,0,0)
	#JUMPself.remove(game.level.roommanager.room.entities)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame
from pygame.locals import *

from entity import *

from random import *
import os
from utility import *

class Wallwalksmallcave(Entity):
    def __init__(self,x,y,w,h,dungeonnumber,keynumber):
        Entity.__init__(self,x,y,w,h)
        self.addimage('wallwalksmallcave1.bmp',0,0,0)

        self.counter = 0
        self.dungeonnumber = dungeonnumber
        self.keynumber = keynumber


    def update(self,room):
	if self.counter > 1:
	    self.counter -= 1
	else:
	    self.remove(room.entities)
        #1

    def remove(self,list):
	if self.counter == 1:
            list.remove(self)
	    return 1
        ### return None 
        string = "You have a yellow ring"
        string += self.keynumber
        string += " - dungeon "
        string += self.dungeonnumber
        string = "\n"
        print "foo"

        if Utilities().readandfindstring(string):
            print "You walk through the wall with the yellow ring"
            ### JUMP NOTElist.remove(self)
            return 1
        
        #return None
	return 1


    def useyellowring(self,game):
        string = "You have destroyed a wall"
        string += "\n"
        print "BAZ"
	self.counter = 22
	self.imagescounter = 0
        self.maximages = 0
	self.images = [] 
        self.addimage('wallwalksmallcave2.bmp',0,0,0)
        self.addimage('wallwalksmallcave2.bmp',0,0,0)
        self.addimage('wallwalksmallcave3.bmp',0,0,0)
        self.addimage('wallwalksmallcave3.bmp',0,0,0)
        self.addimage('wallwalksmallcave4.bmp',0,0,0)
        self.addimage('wallwalksmallcave4.bmp',0,0,0)
        self.addimage('wallwalksmallcave5.bmp',0,0,0)
        self.addimage('wallwalksmallcave5.bmp',0,0,0)
        self.addimage('wallwalksmallcave6.bmp',0,0,0)
        self.addimage('wallwalksmallcave6.bmp',0,0,0)
        self.addimage('wallwalksmallcave7.bmp',0,0,0)
        self.addimage('wallwalksmallcave7.bmp',0,0,0)
        self.addimage('wallwalksmallcave8.bmp',0,0,0)
        self.addimage('wallwalksmallcave8.bmp',0,0,0)
        self.addimage('wallwalksmallcave9.bmp',0,0,0)
        self.addimage('wallwalksmallcave9.bmp',0,0,0)
	#JUMPself.remove(game.level.roommanager.room.entities)

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


from enemytalking import *
from talksystemwaterdevilfemale import *
from entityfactory import *
from food import *

class Waterdevilfemale(Enemytalking):
    def __init__(self,x,y,w,h):
        Enemytalking.__init__(self,x,y,w,h,Talksystemwaterdevilfemale())
        self.addimage('waterdevilfemale1.bmp',255,255,255)
	# blink eyes graphic
        self.addimage('waterdevilfemaleblink1.bmp',255,255,255)
        self.counter = 0


####### TEXT / FONT interface
    def getname(self,text):
        return text.getwaterdevilfemalename()

#    def gettalk(self):
#        talksystem.gettalk(self)
    def update(self,room):
	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 180:
            self.counter = 0

        if self.counter < 85:
            screen.scr.blit(self.images[0], (self.x, self.y))
        else:
            screen.scr.blit(self.images[1], (self.x, self.y))
	 

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the waterdevilfemale."
            return 1
        else:
            return None

# Copyright (C) Johan Ceuppens 2011
# Copyright (C) Johan Ceuppens 2010

# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


#from bouncer import *
from enemytalking import *
from talksystemwaterdevil import *
from entityfactory import *
from food import *

class Waterdevil(Enemytalking):#Bouncer):
    def __init__(self,x,y,w,h, boxes):
        Enemytalking.__init__(self,x,y,w,h,Talksystemwaterdevil())
        self.addimage('waterdevil1.bmp',255,255,255)
        self.addimage('waterdevil2.bmp',255,255,255)
        self.addimage('waterdevil3.bmp',255,255,255)
        self.counter = 0

	self.direction = 1 
	self.boxes = boxes

####### TEXT / FONT interface
    def getname(self,text):
        return text.getwaterdevilname()

#    def gettalk(self):
#        talksystem.gettalk(self)
#    def update(self,room):
#	1

####### other methods
    def draw(self,screen):
        self.counter += 1

        if self.counter >= 40:
            self.counter = 0

        if self.counter < 10:
            screen.scr.blit(self.images[0], (self.x, self.y))
        elif self.counter < 20:
            screen.scr.blit(self.images[1], (self.x, self.y))
        elif self.counter < 30:
            screen.scr.blit(self.images[2], (self.x, self.y))
        elif self.counter < 40:
            screen.scr.blit(self.images[1], (self.x, self.y))
        

#     def leftbuttonpressed(self,mouse,text):
#         return self.talksystem.gettalk(text)#foo

    def remove(self,list):
        if self.hitpoints <= 0:
            list.remove(self)

	    # LEAVE & ADD FOOD AT RANDOM
	    if randint(0,4) == 3:
		print ("The waterdevil drops some food.")
        	#factory = Entityfactory()
                #o = factory.make(Entity.ENTITY_FOOD,
		o = Food(self.x,self.y,40,40)#FIXME Maproom x, y!
	        list.add(o)
	
    def leftbuttonpressedwithinventoryitem(self,game):
        if Enemytalking.leftbuttonpressedwithinventoryitem(self,game):
            print "You use the item on the waterdevil."
            return 1
        else:
            return None



    def collisionboxes(self):
        o = self.collisionlist(self.boxes)
        
        if o:
            #player.bounceback()#FIXME1 level arg
            return 1
        return None

    def update(self,room):#FIXME all level arg must be room
	o = None
	o = self.collisionboxes()

	if o:
	    r = randint(0,40)
	    if r < 2:
	        self.bounceback(None) 	
        if self.direction == 1:#north
	     self.y -= 1
        elif self.direction == 3:#south
 	     self.y += 1
        elif self.direction == 4:#west
             self.x -= 1
        elif self.direction == 2:#east
	     self.x += 1

    def bounceback(self,level):
        if self.direction == 1:#north
	    self.y += 12 
	   # self.direction = 3 
        elif self.direction == 3:#south
	    self.y -= 12
	   # self.direction = 1 
        elif self.direction == 4:#west
	    self.x -= 12
	   # self.direction = 2 
        elif self.direction == 2:#east
	    self.x += 12
	   # self.direction = 4 
	# set direction
	r = randint(1,4)
	self.direction = r

    def collisionlist(self,list):
        return self.collisionlist1(self,list)

    # GEN PROC
    def collisionlist1(self,collider,list):
        for i in range(0,list.length):
            o = None
            o = list.getlistobject(o)
            
            if o:
#                print 'i=%d x=%d y=%d px=%d py=%d' % (i, o.x,o.y,collider.x,collider.y)
                if collider.x >= o.x and collider.x <= o.x + o.w and collider.y >= o.y and collider.y <= o.y + o.h :   	
                    return o
        return None



# Copyright (C) Johan Ceuppens 2009 
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.

# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.


import pygame

#from Numeric import *
#import pygame.surfarray as surfarray

from pygame.locals import *
from room import *
from roomroomman import *
from roomdungeon1 import *
from roomdungeon2 import *
from map import *
from box import *
from exitbox import *
from ooze import *
from ent import *
from tree import *
from tree2 import *
from tree3 import *
from tree4 import *
from movingwallnorth import *
from movingwallsouth import *
from movingwallwest import *
from movingwalleast import *
from treestone import *
from entstone import *
from bat import *
from skeleton import *
from skeleton2 import *
from dragon import *
from dracolich import *
from myconid import *
from koboldmage import *
from chest1 import *
from chestmanapotion import *
from key import *
from key2 import *
from key3 import *
from wallwalk import *
from wallwalksmallcave import *
from wallwalk2 import *
from lockeddoornorth import *
from lockeddoornorth2 import *
from lockeddoorsouth import *
from lockeddooreast import *
from lockeddooreast2 import *
from lockeddoorwest import *
from lockeddoorgreywalleast import *
from spellbookdracolich import *
from spellbooknootie import *
#from mapworld import *
from maproomleftright import *
from maproomupdown import *
from maproom import *
from maproomchbg import *
from roomchbg import *
from inventoryspellbookdracolich import *
from hobgoblinswordsman1 import *
from movingplatform1 import *
from sword1blue import *
from ringblue import *
from ringyellow import *
from scrollinvisibility import *

class Room1world(Room):
    ""
    def __init__(self, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadworldroom1()
        return self


    def loadworldroom1(self):
        
        factory = Entityfactory()
        self.addfactory(factory)

        self.addentity(factory.make(Entity.ENTITY_TREE2, 0,0,130,130))
#        self.addentity(factory.make(Entity.ENTITY_TREE2,500,0,130,130))
#        self.addentity(factory.make(Entity.ENTITY_TREE2,200,0,130,130))

#        self.addentity(factory.make(Entity.ENTITY_TREE2,300,0,130,130))
#        self.addentity(factory.make(Entity.ENTITY_TREE2,100,0,130,130))
#        self.addentity(factory.make(Entity.ENTITY_TREE2,400,0,130,130))

        self.addentity(factory.make(Entity.ENTITY_TREE2,100,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE3,0,200,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,300,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE3,450,100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,200,130,130))        
        self.addentity(factory.make(Entity.ENTITY_TREE3,500,300,130,130))
        

#        self.addentity(factory.make(Entity.ENTITY_FOOD,300,100,20,20))

#        self.addenemy(factory.make(Entity.ENTITY_SKELETON2,400,390,50,50))     #         self.addenemy(factory.make(Entity.ENTITY_SKELETON2,450,390,50,50))

        # WALLS DUNGEON ENTRANCE
#        self.addbox(250,170,100,130)
#        self.addbox(250,170,180,60)
#
        # EAST EXIT
#        self.addexit(580,0,100,400,3001,310,230,Worldmaproom1(0,-520))
        # WEST EXIT
#        self.addexit(0,200,60,60,1.6,570,210)

        # NORTH EXIT
        self.addexit(0,0,640,80,3001,310,230,Roomforest1(0,-420, self.roomman))

        # DUNGEON 1 GATE
#        self.addexit(350,200,90,80,1.1,210,390,Room1dungeon1())

        # SOUTH EXIT
        self.addexit(0,430,640,50,1002,210,90,Room2world(self.roomman))

        # EXITS
#        self.addexit(0,0,640,100,1,100,100)

        if Spellbookdracolich(0,0,0,0,"2","1").readspellbook(None):
            angel = factory.make(Entity.ENTITY_ANGEL,250,300,80,80)
            self.addenemy(angel)

        self.background = pygame.image.load('worldroom1.bmp').convert()





class Room2world(Room):
    ""
    def __init__(self, roomman):
        Room.__init__(self)
	self.roomman = roomman
	


    def loadroom(self):
        self.initroom()
        self.loadworldroom2()
        return self

    def loadworldroom2(self):


        factory = Entityfactory()
        # LEFT TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,-20,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,30,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,130,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,230,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,330,130,130))

        # RIGHT TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,-20,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,30,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,130,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,230,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,330,130,130))

        # NORTH TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,300,-20,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,400,-20,130,130))

        # SOUTH TREES

        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,430,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,430,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,200,430,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,450,430,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,620,430,130,130))



#        
#        self.addenemy(Skeleton2night(400,90,50,50))

        # NORTH EXIT
        self.addexit(0,0,640,50,1001,350,420,Room1world(self.roomman))
        # SOUTH EXIT
        self.addexit(0,430,640,50,1003,350,60,Room3world(self.roomman))

        self.background = pygame.image.load('worldroom2.bmp').convert()

class Room3world(Room):
    ""
    def __init__(self, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadworldroom3()
        return self


    def loadworldroom3(self):
        factory = Entityfactory()
        # SOUTH TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,400,330,130,130))        
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,330,130,130))

        # LEFT TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,-20,130,130))        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,30,130,130))        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,130,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,230,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,330,130,130))

        # RIGHT TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,-20,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,30,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,130,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,230,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,330,130,130))


        # EAST EXIT
#        self.addexit(580,200,60,60,1.12,70,210)
        # WEST EXIT
#        self.addexit(0,200,60,60,1.6,570,210)
        # NORTH EXIT
        self.addexit(0,0,640,50,1002,350,420,Room2world(self.roomman))
        # SOUTH EXIT
        self.addexit(0,430,640,50,1004,350,60,Room4world(self.roomman))

        self.background = pygame.image.load('worldroom1.bmp').convert()






   

class Room4world(Room):
    "right of Nut Grove"
    def __init__(self, roomman):
        Room.__init__(self)
	self.roomman = roomman
#        Room.__init__(screen)



    def loadroom(self):
        self.initroom()
        self.loadworldroom4()
        return self

    def loadworldroom4(self):

        factory = Entityfactory()
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,100,-20,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,100,260,130,130))


        # LEFT TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,-20,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,30,130,130))
        
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,230,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,330,130,130))

        # RIGHT TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,-20,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,30,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,130,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,230,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,330,130,130))

        # RIGHT of TREES EAST EXIT towards east gnarborean woods
        # WEST EXIT
        self.addexit(0,0,60,480,3030,500,210,NutGrove1(0,0,self.roomman))
        # NORTH EXIT
        self.addexit(0,0,640,50,1003,350,420,Room3world(self.roomman))
        # SOUTH EXIT
        self.addexit(0,430,640,50,1005,250,60,Room5world(self.roomman))

        self.background = pygame.image.load('worldroom4.bmp').convert()


class Room5world(Room):
    ""
    def __init__(self, roomman):
        Room.__init__(self)
	self.roomman = roomman
#        Room.__init__(screen)

    def loadroom(self):
        self.initroom()
        self.loadworldroom5()
        return self

    def loadworldroom5(self):

        factory = Entityfactory()
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,100,0,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,0,130,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,100,130,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,230,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,330,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,330,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,100,430,130,130))


#        self.addentity(factory.make(Entity.ENTITY_TREE3,100,130,130,130))
        
#        self.addentity(factory.make(Entity.ENTITY_TREE3,200,130,130,130))
#        self.addentity(factory.make(Entity.ENTITY_TREE3,300,130,130,130))

        # MIDDLE TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,400,0,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,400,100,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,400,200,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,400,300,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,400,400,130,130))
        # RIGHT MIDDLE TREE
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,520,50,130,130))
        # RIGHT TREES
#         
#         self.addentity(factory.make(Entity.ENTITY_TREE2,610,50,130,130))
#         
#         self.addentity(factory.make(Entity.ENTITY_TREE2,610,150,130,130))
#         
#         self.addentity(factory.make(Entity.ENTITY_TREE2,610,250,130,130))
#         
#         self.addentity(factory.make(Entity.ENTITY_TREE2,610,350,130,130))
#         
#         self.addentity(factory.make(Entity.ENTITY_TREE2,610,450,130,130))

        # EAST EXIT
        self.addexit(600,0,40,480,3030,50,210,Room7world(self.roomman))
#        self.addexit(580,200,60,60,1.12,70,210)
        # WEST EXIT
#        self.addexit(0,200,60,60,1.6,570,210)

        # NORTH EXIT
        self.addexit(0,0,640,50,1004,350,420,Room4world(self.roomman))
        # LEFT SOUTH EXIT
        self.addexit(0,430,400,50,1006,250,60,Room6world(self.roomman))
        # RIGHT SOUTH EXIT
        self.addexit(530,430,110,50,1006,540,60,Room6world(self.roomman))

        self.background = pygame.image.load('worldroom5.bmp').convert()


class Room6world(Room):
    "With Dracolich Dungeon entrance"
    def __init__(self, roomman):
        Room.__init__(self)
	self.roomman = roomman
#        Room.__init__(screen)

    def loadroom(self):
        self.initroom()
        self.loadworldroom6()
        return self


    def loadworldroom6(self):
        factory = Entityfactory()
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,-50,0,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,-50,100,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,130,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,230,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,330,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,100,330,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE3,100,430,130,130))

        # SOUTH TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,200,330,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,300,330,130,130))
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,400,330,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,500,330,130,130))

        # MIDDLE TREES
        
        self.addentity(factory.make(Entity.ENTITY_TREE2,300,0,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,300,100,130,130))

	# RIGHT TREES
        self.addentity(factory.make(Entity.ENTITY_TREE2,550,0,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,550,100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,550,200,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,550,300,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,550,400,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE2,550,500,130,130))

        # STAIRS EXIT
        self.addexit(120,60,40,70,201,210,100,Room1dungeon2(self.roomman))


        # EAST EXIT
        # WEST EXIT
        # LEFT NORTH EXIT
        self.addexit(0,0,400,50,1005,250,420,Room5world(self.roomman))
        # RIGHT NORTH EXIT
        self.addexit(430,0,110,50,1005,540,420,Room5world(self.roomman))

        # LEFT SOUTH EXIT
#        self.addexit(0,430,400,50,1006,250,60)
        # RIGHT SOUTH EXIT
#        self.addexit(530,430,110,50,1006,540,60)

        self.background = pygame.image.load('worldroom6.bmp').convert()

class Room7world(Room):
    "East of Dracolich Dungeon entrance"
    def __init__(self, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadworldroom6()
        return self


    def loadworldroom6(self):
        factory = Entityfactory()
        
        self.addentity(factory.make(Entity.ENTITY_TREE3,100,430,130,130))

        # SOUTH TREES
        
        # MIDDLE TREES
        
	# RIGHT TREES

        # STAIRS EXIT

        # EAST EXIT
        # WEST EXIT
        self.addexit(0,0,40,480,1005,550,200,Room5world(self.roomman))
        # LEFT NORTH EXIT
#        self.addexit(0,0,400,50,1005,250,420,Room5world(self.roomman))
        # RIGHT NORTH EXIT
#        self.addexit(430,0,110,50,1005,540,420,Room5world(self.roomman))
        # LEFT SOUTH EXIT
#        self.addexit(0,430,400,50,1006,250,60)
        # RIGHT SOUTH EXIT
#        self.addexit(530,430,110,50,1006,540,60)

        self.background = pygame.image.load('worldroom7.bmp').convert()


###############################################################################
###############################################################################
###############################################################################
# DUNGEON 2 - DRACOLICH DUNGEON
###############################################################################
###############################################################################
###############################################################################



class Room1dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room1()
        return self

    def loaddungeon2room1(self):
        factory = Entityfactory()
        # LAVA 
        self.addbox(70,100,130,100)
        self.addbox(270,100,300,280)
        self.addbox(70,280,210,100)

        
        self.addenemy(Bat(300,200,50,50))        
        self.addenemy(Bat(350,100,50,50))

        # DOOR SOUTH
#        
#        self.addentity(Lockeddoorsouth(200,400,80,80,"1","3"))


#         
#         self.addentity(Key(300,300,40,40,"1","4"))

#         self.readkeys("1","4")



        # EAST EXIT
#        self.addexit(580,200,60,90,202,250,300)
        # WEST EXIT
        self.addexit(0,200,60,60,202,570,210,Room2dungeon2(self.roomman))
        # NORTH EXIT
        self.addexit(200,0,90,80,1006,180,90,Room6world(self.roomman))
        # SOUTH EXIT
#        self.addexit(200,400,60,80,1001,210,90)

        self.background = pygame.image.load('room1dungeon2.bmp').convert()
       

class Room2dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room2()
        return self


    def loaddungeon2room2(self):
        factory = Entityfactory()
        # LAVA 
        self.addbox(0,0,360,200)

        self.addbox(360,90,220,110)
        self.addbox(360,280,200,110)
#        self.addbox(70,280,210,100)

#        
#        self.addenemy(Bat(400,300,50,50))
#        self.addenemy(Bat(450,100,50,50))

        self.addenemy(factory.make(Entity.ENTITY_MYCONID,200,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,250,220,50,50))


        # DOOR SOUTH
#        
#        self.addentity(Lockeddoorsouth(200,400,80,80,"1","3"))


#         
#         self.addentity(Key(300,300,40,40,"1","4"))

#         self.readkeys("1","4")



        # EAST EXIT
        self.addexit(580,200,60,90,202,90,210,Room1dungeon2(self.roomman))
        # WEST EXIT
        self.addexit(0,200,60,280,202,500,220,Room3dungeon2(self.roomman))
        # NORTH EXIT
#        self.addexit(200,0,90,80,1006,180,90)
        # SOUTH EXIT
#        self.addexit(200,400,60,80,1001,210,90)

        self.background = pygame.image.load('room2dungeon2.bmp').convert()
       



class Room3dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room3()
        return self


    def loaddungeon2room3(self):
        factory = Entityfactory()

        # LAVA 
        self.addbox(400,0,240,200)


        self.addenemy(factory.make(Entity.ENTITY_MYCONID,300,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,350,250,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,400,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,450,250,50,50))


        # EAST EXIT
        self.addexit(580,0,60,480,102,70,210,Room2dungeon2(self.roomman))
        # NORTH EXIT
        self.addexit(0,0,400,80,104,200,390,Room4dungeon2(self.roomman))


        self.background = pygame.image.load('room3dungeon2.bmp').convert()
       
class Room4dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room4()
        return self


    def loaddungeon2room4(self):
        factory = Entityfactory()

        # LAVA 
        self.addbox(400,0,240,200)
        self.addbox(400,280,240,200)

        self.addenemy(factory.make(Entity.ENTITY_MYCONID,220,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,270,100,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,420,210,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,460,210,50,50))


        # EAST EXIT
        self.addexit(580,200,80,80,102,70,210,Room7dungeon2(self.roomman))

       # NORTH EXIT
        self.addexit(60,0,340,90,103,200,390,Room5dungeon2(self.roomman))

       # SOUTH EXIT
        self.addexit(60,400,400,60,103,200,100,Room3dungeon2(self.roomman))


        self.background = pygame.image.load('room4dungeon2.bmp').convert()
       

class Room5dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room5()
        return self


    def loaddungeon2room5(self):
        factory = Entityfactory()

        self.addenemy(factory.make(Entity.ENTITY_MYCONID_RED,200,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID_RED,250,100,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID_RED,400,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID_RED,450,100,50,50))


        # EAST EXIT
        self.addexit(580,100,60,80,106,70,280,Room6dungeon2(self.roomman))
       # SOUTH EXIT
        self.addexit(60,400,400,60,103,200,110,Room4dungeon2(self.roomman))


        self.background = pygame.image.load('room5dungeon2.bmp').convert()
       


class Room6dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room6()
        return self


    def loaddungeon2room6(self):
        factory = Entityfactory()

        self.addenemy(factory.make(Entity.ENTITY_EARTHWEIRD,400,200,50,50))

        key = Key(200,200,40,40,"2","1")
        if not key.readkeys(self.entities):###FIXME11
            self.addentity(key)
	    

#        self.addenemy(factory.make(Entity.ENTITY_MYCONID_RED,200,300,50,50))


        # WEST EXIT
        self.addexit(0,260,60,80,105,570,110,Room5dungeon2(self.roomman))

        self.background = pygame.image.load('room6dungeon2.bmp').convert()
       



class Room7dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman 

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room7()
        return self


    def loaddungeon2room7(self):
        factory = Entityfactory()

        self.addbox(250,0,390,320)

        self.addenemy(factory.make(Entity.ENTITY_MYCONID,100,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,150,100,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,400,300,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,450,100,50,50))


        # WEST EXIT
        self.addexit(0,210,60,80,105,570,210,Room4dungeon2(self.roomman))
        # EAST EXIT
        self.addexit(570,320,60,80,108,70,240,Room8dungeon2(self.roomman))

        self.background = pygame.image.load('room7dungeon2.bmp').convert()
       




class Room8dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room8()
        return self


    def loaddungeon2room8(self):
        factory = Entityfactory()

        self.addbox(0,0,640,180)
        self.addbox(0,300,640,180)

#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,100,300,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,150,100,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,400,300,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,450,100,50,50))

        self.addentity(Lockeddoorgreywalleast(560,200,80,80,"2","1"))

        # WEST EXIT
        self.addexit(0,200,60,80,107,560,340,Room7dungeon2(self.roomman))
        # EAST EXIT
        self.addexit(570,200,60,80,109,310,90,Room9dungeon2(self.roomman))

        self.background = pygame.image.load('room8dungeon2.bmp').convert()
       

class Room9dungeon2(Roomdungeon2):
    ""

    def __init__(self, roomman):
        Roomdungeon2.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loaddungeon2room9()
        return self


    def loaddungeon2room9(self):
        factory = Entityfactory()

#        self.addbox(0,0,640,180)
#        self.addbox(0,300,640,180)

#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,100,300,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,150,100,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,400,300,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,450,100,50,50))


        dracolich = Dracolich(200,200,40,40,"2","1") 	
        self.addenemy(dracolich)
        if dracolich.readboss(self.entities):
	     
            spellbook = Spellbookdracolich(100,100,80,80,"2","1")
            self.addenemy(spellbook)
            spellbook.readspellbook(self.entities)


        self.addenemy(factory.make(Entity.ENTITY_SKELETON2,400,290,50,50))  
        self.addenemy(factory.make(Entity.ENTITY_SKELETON2,470,290,50,50))



        # NORTH EXIT
        self.addexit(300,0,60,80,108,560,210,Room8dungeon2(self.roomman))

        self.background = pygame.image.load('room9dungeon2.bmp').convert()
  

#def loaddungeon2room10(self):
#        factory = Entityfactory()

#        self.addbox(0,0,640,180)
#        self.addbox(0,300,640,180)

#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,100,300,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,150,100,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,400,300,50,50))
#        self.addenemy(factory.make(Entity.ENTITY_MYCONID,450,100,50,50))


        # WEST EXIT
#        self.addexit(0,200,60,80,107,570,210,Room9dungeon2(self.roomman))
        # EAST EXIT
#        self.addexit(590,200,60,80,109,70,210,Room9dungeon2())

#        self.background = pygame.image.load('room9dungeon2.bmp').convert()
  

###############################################################################
###############################################################################
###############################################################################
# (BIG) WORLD MAPS
###############################################################################
###############################################################################
###############################################################################


class Maproom1(Maproom):
    ""

    def __init__(self):
        Maproom.__init__(self,-100,-100)
        self.loadwalls()

    def loadwalls(self):
        
        # NORTH WALL
        self.addbox(0,0,640,80)
        # SOUTH WALL
        self.addbox(0,400,640,80)
        # WEST WALL
        self.addbox(0,0,60,480)
        # EAST WALL
        self.addbox(580,0,60,480)


    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):
        factory = Entityfactory()

#         # LAVA 
 #       self.addbox(400,0,240,200)


        self.addenemy(factory.make(Entity.ENTITY_MYCONID,300,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,350,250,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,400,300,50,50))
        self.addenemy(factory.make(Entity.ENTITY_MYCONID,450,250,50,50))

	
#         # EAST EXIT
#         self.addexit(580,0,60,480,102,70,210,Room2dungeon2())
#         # NORTH EXIT
#         self.addexit(0,0,400,80,104,200,390,Room4dungeon2())

        self.background = pygame.image.load('room1dungeon2.bmp').convert()





class Roomforest1(Maproom):
    "NORTH of START"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman
#        self.loadwalls()

#     def loadwalls(self):
        
#         # NORTH WALL
#         self.addbox(0,0,640,80)
#         # SOUTH WALL
#         self.addbox(0,400,640,80)
#         # WEST WALL
#         self.addbox(0,0,60,480)
#         # EAST WALL
#         self.addbox(580,0,60,480)


    def loadroom(self):
	#self.screen = foo.screen#NOTE89
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):
        factory = Entityfactory()

        self.addentity(factory.make(Entity.ENTITY_TREE4, 10,0,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,500,0,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,200,0,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,100,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,10,100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,10,200,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,100,250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,0,300,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,500,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE4,450,100,130,130))

	#self.addentity(Movingplatform1(0,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_PLATFORMMAPROOM1,0,100,70,70))

        # NORTH EXIT
        self.addexit(0,0,1000,200,3004,300,190,Worldmaproom2(-200,-570, self.roomman))
        # SOUTH EXIT
        self.addexit(0,800,1000,200,3004,300,90,Room1world(self.roomman))
        # WEST EXIT  
        self.addexit(0,0,100,1000,3004,300,90,Roombirdforest(-700,0,self.roomman))

       
	self.background = pygame.image.load('worldmaproom1.bmp').convert()


class Worldmaproom2(Maproom):
    "River leading to the Sea of Twilight"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

       # img = pygame.image.load('rect1.bmp').convert()
       # rect.set_colorkey((0,0,0))
       # rect  = pygame.draw.rect(self.screen, 0x0ff0000)
#        self.background = pygame.image.load('bg_forest1.bmp').convert()
#        self.screen.scr.blit(self.background, (0, 0))
       # screen.draw(self.entities)
#        pygame.display.update()
        
	factory = Entityfactory()

        # ENEMIES
	# FIXME
        #mage = factory.make(Entity.ENTITY_KOBOLDMAGE,450,800,130,130)
        #self.addenemy(mage)
        #mage.readkoboldmage(self.entities)
        #orcblue = factory.make(Entity.ENTITY_ORCBLUE,450,800,130,130)
        #self.addenemy(orcblue)
            

        #self.addentity(factory.make(Entity.ENTITY_TREE4, 10,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,200,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,100,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,200,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,250,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,0,300,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,450,100,130,130))

	# RIVER
        self.addbox(1000,250,400,500)
	# PONT
        #self.addbox(2300,825,100,535)
	
	# EXIT IN WATER
        self.addexit(1200,760,100,100,3008,300,200,Worldmaproom2water(-850,-450, self.roomman))
        # NORTH EXIT
        self.addexit(0,0,1400,100,3007,300,200,Worldmaproom3water(0,-750, self.roomman))
         # SOUTH EXIT
        self.addexit(0,800,1000,200,3004,300,140,Roomforest1(0,-100, self.roomman))

        orcpaladin = factory.make(Entity.ENTITY_ORCPALADIN,250,200,60,60)
        self.addenemy(orcpaladin)
        self.background = pygame.image.load('bg_forest2.bmp').convert()




class Worldmaproom2water(Maproom):
    "In revier siwmming - Sea of Twilight"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# WALLS
	self.addbox(1000,250,400,122)
	self.addbox(1000,250,12,500)
	self.addbox(1000,750,400,12)
	# ENEMIES
	# FIXME
        #mage = factory.make(Entity.ENTITY_KOBOLDMAGE,450,800,130,130)
        #self.addenemy(mage)
        #mage.readkoboldmage(self.entities)
        #hobgoblin1 = factory.make(Entity.ENTITY_HOBGOBLINSWORDSMAN1,450,800,30,30)
        #self.addenemy(hobgoblin1)


        # SOUTH EXIT
	# EXIT OUT OF WATER
        self.addexit(1200,700,100,100,3008,300,200,Worldmaproom2(-900,-700, self.roomman))
        # EAST IN WATER EXIT
        self.addexit(1350,250,50,500,3010,300,200,Worldmaproom3water(0,-750, self.roomman))

        self.background = pygame.image.load('bg_forest2.bmp').convert()




class Worldmaproom3water(Maproom):
    "Sea of Twilight"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# WATER FORTRESS WALLS
	self.addbox(1840,1350,560,85)
	self.addbox(1840,1600,40,800)
	# EXIT LEFT OF WATER
        self.addexit(0,0,100,2400,3008,300,200,Worldmaproom2water(-900,-200, self.roomman))
	# EXIT RIGHT OF WATER TO WATER FORTRESS
        self.addexit(1840,1440,40,160,3008,300,200,Worldmaproomwaterfortress1(-1600,-1300, self.roomman))

        self.background = pygame.image.load('bg_water3.bmp').convert()

class Worldmaproomwaterfortress1(Maproom):
    ""

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
       
	# DEMON'S CRAG ENEMIES 
#	hobgoblin1 = factory.make(Entity.ENTITY_HOBGOBLINSWORDSMAN1,1900,1600,30,30)
#        self.addenemy(hobgoblin1)
#        hobgoblin2 = factory.make(Entity.ENTITY_HOBGOBLINSWORDSMAN1,2000,1600,30,30)
#        self.addenemy(hobgoblin2)
#        hobgoblin3 = factory.make(Entity.ENTITY_HOBGOBLINSWORDSMAN1,2200,1800,30,30)
#        self.addenemy(hobgoblin3)

	#demon1 = factory.make(Entity.ENTITY_DEMON1,1970,1800,30,30)
        #self.addenemy(demon1)
        self.addenemy(factory.make(Entity.ENTITY_HOUNDARCHON1,1970,1800,60,60))
	
	# WATER FORTRESS WALLS
	self.addbox(1840,1350,560,85)
	self.addbox(1840,1600,40,800)
	# PIT
	self.addbox(2000,1930,240,220)

	# EXIT LEFT OF WATER FORTRESS
        self.addexit(1840,1440,40,160,3008,300,200,Worldmaproom3water(-1450,-1300, self.roomman))
	# EXIT TEMPLE 
        self.addexit(2300,1600,100,100,3008,300,200,Worldmapinsidetemple1(0,-700, self.roomman))

        self.background = pygame.image.load('bg_water3.bmp').convert()



class Dungeonwater4(Maproom):
    ""

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,210,100)
	self.addbox(290,0,600,100)
	self.addbox(0,0,100,400)
	self.addbox(0,500,100,400)
	self.addbox(0,800,900,100)
	#RIGHT WALL
	self.addbox(800,0,100,200)
	self.addbox(800,300,100,600)
	# ENEMIES
	# FIXME
        #mage = factory.make(Entity.ENTITY_KOBOLDMAGE,450,800,130,130)
        #self.addenemy(mage)
        #mage.readkoboldmage(self.entities)
        #hobgoblin1 = factory.make(Entity.ENTITY_HOBGOBLINSWORDSMAN1,450,800,30,30)
        #self.addenemy(hobgoblin1)
        
	#self.addentity(factory.make(Entity.ENTITY_TREE4, 10,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,200,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,100,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,200,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,250,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,0,300,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,450,100,130,130))

        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,250,100,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,350,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,150,250,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,250,110,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,90,70,70, self.boxes))

	# STATUES
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUE,700,100,100,100))
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUE,700,300,100,100))
	
        self.addentity(Lockeddoornorth2(200,0,100,100,"3","1"))
         # NORTH EXIT TO CHERUB ROOM, DOOR
	self.addexit(220,0,80,80,3008,300,420,Roomdungeonwatercherubs(self.roomman))#(0,0))#, self.roomman))
         # WEST EXIT
        self.addexit(0,400,50,100,3008,300,90,Worldmapinsidetemple1(-800,-50, self.roomman))
        self.addentity(Lockeddooreast2(800,200,100,100,"3","2"))
         # EAST EXIT, DOOR
        self.addexit(810,210,80,80,3040,150,250,Dungeonwater5(0,-550, self.roomman))

        self.background = pygame.image.load('bg_dungeonwater4.bmp').convert()

class Dungeonwater5(Maproom):
    "Room in water dungeon with yellow ring use (wallwalk.py)"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,650,250,100)
	self.addbox(0,850,900,100)
	self.addbox(900,0,100,1000)
	self.addbox(250,0,750,100)
	self.addbox(250,0,100,250)
	self.addbox(250,350,100,400)
	# HIDDEN ROOM WALLS
	self.addbox(0,0,200,200)
	self.addbox(0,0,20,400)
	self.addbox(0,400,200,20)
	self.addbox(200,240,40,20)
	self.addbox(200,350,40,20)

	# ENEMIES
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,300,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,550,400,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,750,700,70,70, self.boxes))

        #self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,90,70,70, self.boxes))

	# STATUES
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUE,250,650,100,100))

	# ITEMS
        #key = Scrollinvisibility(80,280,50,50,"3","1")

	# DOORS
        #self.addentity(key)
        #key.readkeys(self.entities)
        self.addentity(Wallwalk(250,250,100,100,"3","1"))
	
        # HIDDEN ROOM STAIRS
	self.addexit(80,280,50,50,3008,300,220,Dungeonwaterlower1(-350,0,self.roomman))
         # WEST EXIT
        self.addexit(0,750,50,100,3008,300,220,Dungeonwater4(-400,0, self.roomman))
        # NORTH STAIRS UP EXIT
	self.addexit(500,150,50,50,3008,420,250,Dungeonwater6(self.roomman))

        self.background = pygame.image.load('bg_dungeonwater51.bmp').convert()

class Dungeonwater6(Roomroomman):
    ""

    def __init__(self,roomman):
        Roomroomman.__init__(self,roomman)
	
    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,40,300)
	self.addbox(0,0,640,40)
	self.addbox(0,600,40,480)
	self.addbox(0,440,640,40)
	
	self.addbox(0,360,40,120)
	# WATER BELOW PIT
	self.addbox(0,360,100,30)
	self.addbox(100,250,240,230)
	# DEEP WATER
	# self.addbox(380,80,165,320)
	# ENEMIES
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,750,700,70,70, self.boxes))

	# STATUES
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,100,100,50,50))
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,150,100,50,50))
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,200,100,100,100))
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,250,100,50,50))
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,300,100,50,50))
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,350,100,50,50))
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,100,150,50,50))
        #self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,350,150,50,50))
	
         # WEST EXIT
        self.addexit(0,300,50,50,3008,580,300,Dungeonwater7(self.roomman))
        #  STAIRS DOWN EXIT
	self.addexit(430,330,50,50,3008,300,250,Dungeonwater5(-200,0, self.roomman))

        self.background = pygame.image.load('bg_dungeonwater61.bmp').convert()

class Dungeonwater7(Roomroomman):
    ""

    def __init__(self,roomman):
        Roomroomman.__init__(self,roomman)

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,600,40)
	self.addbox(0,0,40,480)
	self.addbox(0,440,640,40)
	self.addbox(600,0,40,300)
	# PITS
	self.addbox(0,140,150,20)
	self.addbox(240,140,280,20)
	self.addbox(500,140,20,260)
	self.addbox(500,370,140,20)

	# ENEMIES
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,750,700,70,70, self.boxes))

	# STATUES
	
         # EAST UPPER EXIT
        self.addexit(590,300,50,50,3008,60,305,Dungeonwater6(self.roomman))
         # EAST LOWER EXIT
        self.addexit(590,390,50,50,3008,60,410,Dungeonwater6(self.roomman))
        #  HERMIT EXIT
	self.addexit(220,0,55,55,3008,300,300,Dungeonwaterhermit8(self.roomman))

        self.background = pygame.image.load('bg_dungeonwater7.bmp').convert()



class Dungeonwaterlower1(Maproomleftright):
# "room with orc paladins under stairs yellow ring usage"
    def __init__(self,x,y,roomman):
        Maproomleftright.__init__(self, x, y)
	self.roomman = roomman
	
    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,800,40)
	self.addbox(0,440,800,40)
	self.addbox(0,0,40,480)
	self.addbox(760,0,40,480)
	# INNER WALLS
	self.addbox(425,0,40,365)
	self.addbox(425,405,40,65)
	self.addbox(295,0,40,100)
	self.addbox(295,140,40,340)
	# PITS 
	# ENEMIES
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,250,100,60,60, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,450,350,60,60, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,150,250,60,60, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,700,200,60,60, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,500,100,60,60, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,200,300,60,60, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,100,100,60,60, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,600,300,60,60, self.boxes))
	# STATUES
        self.addentity(Wallwalk2(425,365,40,40,"3","2"))
        self.addentity(Wallwalk2(285,103,40,40,"3","3"))
        # EAST EXIT
        self.addexit(750,300,50,50,3008,60,305,Dungeonwater5(-100,0,self.roomman))
        # SOUTH EXIT
	self.addexit(50,425,50,50,3008,305,60,Dungeonwaterlower2(self.roomman))
        self.background = pygame.image.load('bg_dungeonwaterlower1.bmp').convert()

class Dungeonwaterlower2(Room):
    "beautiful assassin's room with scroll"

    def __init__(self,roomman):
        Room.__init__(self)
	self.roomman = roomman
	
    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,640,40)
	self.addbox(0,440,640,40)
	self.addbox(0,0,40,480)
	self.addbox(600,0,40,480)
	# PITS 
	# ITEMS
        scroll = Scrollinvisibility(300,220,50,50,"3","1")
        if not scroll.readkeys(self.entities):
            self.addentity(scroll)
	# ENEMIES
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,600,300,60,60, self.boxes))
	# STATUES
        #self.addentity(Wallwalk2(425,365,40,40,"3","2"))
        #self.addentity(Wallwalk2(285,103,40,40,"3","3"))
        # EAST EXIT
        #self.addexit(750,300,50,50,3008,60,305,Dungeonwater5(-100,0,self.roomman))
        # NORTH EXIT
	self.addexit(300,0,50,50,3050,60,305,Dungeonwaterlower1(0,-60,self.roomman))

        self.background = pygame.image.load('bg_dungeonwaterlower2.bmp').convert()


class Dungeonwaterlowermountains1(Maproom):
    ""

    def __init__(self,x,y,roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman
	
    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,3000,40)
	self.addbox(0,2960,3000,40)
	self.addbox(0,0,40,3000)
	self.addbox(2960,0,40,3000)
	# PITS 
	# ITEMS
	# ENEMIES
	self.addentity(factory.make(Entity.ENTITY_SHIELDMAIDEN,2850,1300,130,130))
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,600,300,60,60, self.boxes))
	# STATUES
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,2150,875,50,50))
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,2050,875,50,50))
        # TREE WALLS
	# NORTH WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, 100,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 200,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 300,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 400,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 500,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 600,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 700,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 800,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 900,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1000,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1200,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1400,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1500,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1600,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1700,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1800,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1900,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2000,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2200,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2300,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2400,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2500,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2600,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2700,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2800,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2900,-80,130,130))
        # SOUTH WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, 100,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 200,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 300,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 400,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 500,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 600,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 700,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 800,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 900,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1000,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1200,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1400,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1500,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1600,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1700,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1800,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1900,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2000,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2200,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2300,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2400,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2500,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2600,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2700,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2800,2950,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2900,2950,130,130))
	# WEST WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,400,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,500,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,600,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,700,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,800,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,900,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1000,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1400,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1500,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1600,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1700,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1800,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,1900,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2000,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2400,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2500,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2600,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2700,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2800,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,2900,130,130))
	# EAST WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,400,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,500,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,600,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,700,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,800,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,900,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1000,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1400,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1500,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1600,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1700,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1800,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,1900,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2000,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2400,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2500,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2600,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2700,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2800,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2950,2900,130,130))


	# EAST  
	self.addentity(factory.make(Entity.ENTITY_TREE5, 130,100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 230,200,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 340,550,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 490,300,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 460,450,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 200,140,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 200,180,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 350,250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 350,200,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 400,250,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 600,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 700,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 750,550,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 650,200,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 600,250,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2600,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2700,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2750,550,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2650,200,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2600,250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2800,300,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2850,350,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2600,600,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2700,620,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2750,650,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2650,700,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2600,750,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2800,780,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2850,850,130,130))
	#   
	self.addentity(factory.make(Entity.ENTITY_TREE5, 200,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,400,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1550,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1650,100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,50,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,400,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1150,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1650,100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,50,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,2500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,2400,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1550,2050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1650,2100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,2050,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,2500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,2400,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2150,2050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2650,2100,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2300,2050,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 100,2500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1700,2300,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 450,2150,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 150,2900,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 300,2050,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 100,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1700,600,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 450,550,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 150,700,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 300,250,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 500,2500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 700,2600,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 450,2650,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 150,2700,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 300,2750,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 200,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 300,600,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 650,650,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 50,700,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 100,750,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1200,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1300,600,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1650,650,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1050,700,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,1750,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 1000,1500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,1600,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1150,1650,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1650,1700,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1600,1750,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 2000,500,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,600,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2150,650,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2650,700,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2600,750,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2500,850,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2300,1050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2200,1050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,1050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2000,1050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2400,1050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2500,1050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2400,1150,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2400,1250,130,130))
	#
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1200,1350,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,450,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1000,1050,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1100,1350,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1600,750,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,750,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2000,250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1400,1250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1500,1250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1600,750,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 2100,750,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1400,2250,130,130))
        self.addentity(factory.make(Entity.ENTITY_TREE5, 1500,2250,130,130))
	
        #self.addentity(Wallwalk2(425,365,40,40,"3","2"))
        #self.addentity(Wallwalk2(285,103,40,40,"3","3"))
        # EAST EXIT
        self.addexit(2940,60,50,50,3019,220,200,Worldmapinsidetemple2(100,100, self.roomman))
        # NORTH-WEST EXIT
        self.addexit(0,0,70,100,3069,300,70,Dungeonwaterlowermountains2(-450,0,self.roomman))
        # CAVE EXIT
	self.addexit(2100,875,50,50,3059,220,60,Dungeonwatermountainscave1(self.roomman))

        self.background = pygame.image.load('bg_dungeonwaterlowermountains1.bmp').convert()


class Dungeonwaterlowermountains2(Maproomleftright):
    ""

    def __init__(self,x,y,roomman):
        Maproomleftright.__init__(self,x,y)
	self.roomman = roomman
	
    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,700,40)
	self.addbox(0,800,200,40)
	self.addbox(0,440,860,40)
	self.addbox(0,0,40,480)
	self.addbox(860,0,40,480)
	# PITS 
	# ITEMS
        #key = Scrollinvisibility(300,220,50,50,"3","1")
        #self.addentity(key)
        #key.readkeys(self.entities)
	# ENEMIES
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_ORCSWORDSMANBLUE,600,300,60,60, self.boxes))
	# STATUES
	# WALLS
	# REST TREES
	self.addentity(factory.make(Entity.ENTITY_TREE5, 690,200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 500,300,130,130))
	# NORTH WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, 0,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 100,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 200,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 300,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 400,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 500,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 600,-80,130,130))
	#self.addentity(factory.make(Entity.ENTITY_TREE5, 700,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 800,-80,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 900,-80,130,130))
	# SOUTH WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, 0,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 100,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 200,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 300,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 400,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 500,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 600,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 700,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 800,410,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 900,410,130,130))
        # WEST WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,0,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, -80,400,130,130))
        # EAST WALL
	self.addentity(factory.make(Entity.ENTITY_TREE5, 890,0,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 890,100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 890,200,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 890,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE5, 890,400,130,130))
	#self.addentity(Wallwalk2(425,365,40,40,"3","2"))
        #self.addentity(Wallwalk2(285,103,40,40,"3","3"))
        # EAST EXIT
        #self.addexit(750,300,50,50,3008,60,305,Dungeonwater5(-100,0,self.roomman))
        # NORTH EXIT
	self.addexit(700,0,100,50,3050,220,200,Dungeonwaterlowermountains1(100,100,self.roomman))

        self.background = pygame.image.load('bg_dungeonwaterlowermountains2.bmp').convert()


class Dungeonwatermountainscave1(Roomroomman):
    ""

    def __init__(self,roomman):
        Roomroomman.__init__(self,roomman)

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,560,50)
	self.addbox(0,0,50,480)
	self.addbox(0,430,560,50)
	self.addbox(500,0,50,480)
	# PITS
	#self.addbox(500,370,140,20)

	# ENEMIES
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,150,170,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,350,170,50,50, self.boxes))

	# STATUES
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,50,50,50,50))
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,470,50,50,50))
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,50,380,50,50))
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUELITTLE,470,380,50,50))
        # NORTH EXIT
	self.addexit(220,0,55,55,3060,220,250,Dungeonwaterlowermountains1(-1850,-700,self.roomman))
        # STAIRS EXIT
	self.addexit(210,200,95,95,3061,220,250,Dungeonwatermountainscave2(-1000,50,self.roomman))

        self.background = pygame.image.load('bg_dungeonwatermountainscave1.bmp').convert()


class Dungeonwatermountainscave2(Maproom):
    ""

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# WALLS
	# room walls
        self.addbox(0,0,1400,100)
        self.addbox(0,0,100,1000)
        self.addbox(1300,0,100,1000)
        #bottom wall self.addbox(1300,0,100,1000)
        # middle walls, top to bottom
        self.addbox(0,250,600,50)
        self.addbox(750,250,375,50)
 
        self.addbox(300,400,725,50)
        self.addbox(1100,250,50,300)
        
	self.addbox(0,550,650,50)
	self.addbox(775,400,50,350)
	
	self.addbox(275,750,500,50)
	
	self.addbox(900,550,100,450)
	# ENEMIES
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,450,470,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,350,270,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,550,770,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,850,170,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,450,710,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,1050,570,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,150,510,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,105,700,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,450,210,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,1050,300,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,540,610,50,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,1000,850,50,50, self.boxes))
	# FIXME
        #mage = factory.make(Entity.ENTITY_KOBOLDMAGE,450,800,130,130)
        #self.addenemy(mage)
        #mage.readkoboldmage(self.entities)
            
        #self.addentity(factory.make(Entity.ENTITY_TREE4, 10,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,200,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,100,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,200,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,250,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,0,300,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,450,100,130,130))


        # NORTH EXIT
        self.addexit(1210,0,190,150,3008,100,300,Dungeonwatermountainscave1(self.roomman))
        # SOUTH EXIT
        self.addexit(150,890,100,110,3008,150,100,Dungeonwatermountainscave3(0,0,self.roomman))

        self.background = pygame.image.load('bg_dungeonwatermountainscave2.bmp').convert()



class Dungeonwatermountainscave3(Maproomupdown):
    ""

    def __init__(self,x,y, roomman):
        Maproomupdown.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# WALLS
	self.addbox(0,0,640,50)
	self.addbox(0,0,50,900)
	self.addbox(0,850,640,50)
	self.addbox(590,0,50,900)
	# ENEMIES
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,450,470,80,80, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,350,270,80,80, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,550,770,80,80, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,550,170,80,80, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,450,710,80,80, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_CHAOSKNIGHT2,150,570,80,80, self.boxes))
        #mage = factory.make(Entity.ENTITY_KOBOLDMAGE,450,800,130,130)
        #self.addenemy(mage)
        #mage.readkoboldmage(self.entities)
            
        # NORTH EXIT
        self.addexit(200,0,50,60,3008,200,300,Dungeonwatermountainscave2(0,-550,self.roomman))
        # SOUTH EXIT
        self.addexit(200,840,50,60,3008,250,250,Dungeonwaterlowermountains2(0,0,self.roomman))

        self.background = pygame.image.load('bg_dungeonwatermountainscave3.bmp').convert()




class Dungeonwaterhermit8(Roomroomman):
    ""

    def __init__(self,roomman):
        Roomroomman.__init__(self,roomman)

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,640,100)
	self.addbox(0,0,140,480)
	self.addbox(0,360,640,120)
	self.addbox(480,0,140,480)
	# PITS
	#self.addbox(500,370,140,20)

	# ENEMIES
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,750,700,70,70, self.boxes))
        self.addenemy(factory.make(Entity.ENTITY_CANDLEFLAME1,195,135,60,60))
        self.addenemy(factory.make(Entity.ENTITY_CANDLEFLAME2,390,135,60,60))
        #self.addenemy(factory.make(Entity.ENTITY_HERMIT,300,150,40,60))

	# STATUES
	
        # SOUTH EXIT
	self.addexit(290,360,55,55,3044,250,60,Dungeonwater7(self.roomman))
        bg = pygame.image.load('bg_dungeonwaterhermit8.bmp').convert()
	shadow = pygame.image.load('bg_dungeonwaterhermit81.bmp').convert()
	shadow2 = pygame.image.load('bg_dungeonwaterhermit8.bmp').convert()
	shadow3 = pygame.image.load('bg_dungeonwaterhermit81.bmp').convert()
        bg.set_alpha(200)
        image = bg
	#buf = bg.get_buffer()#pygame.surfarray.array2d(bg)
	shadow_offset = (1400,1000)
    	image_rect = image.get_rect()
    	shadow_rect2 = shadow2.get_rect()
    	shadow_rect3 = shadow3.get_rect()
    	shadow_rect = shadow.get_rect()
    	shadow_rect.center = image_rect.center
    	shadow_rect.move_ip(shadow_offset)
    	rect = image_rect.union(shadow_rect)
    	result = pygame.Surface(rect.size, pygame.SRCALPHA, 32)
    	result2 = pygame.Surface(rect.size, pygame.SRCALPHA, 32)
    	result3 = pygame.Surface(rect.size, pygame.SRCALPHA, 32)
    	result3.blit(shadow3, (0,0))#(shadow_rect.left - rect.left,shadow_rect.top - rect.top))
    	result3.blit(image, (0,0))#(image_rect.left - rect.left,image_rect.top - rect.top))
    	result2.blit(shadow2, (0,0))#(shadow_rect.left - rect.left,shadow_rect.top - rect.top))
    	result2.blit(image, (0,0))#(image_rect.left - rect.left,image_rect.top - rect.top))
    	result.blit(shadow, (0,0))#(shadow_rect.left - rect.left,shadow_rect.top - rect.top))
    	result.blit(image, (0,0))#(image_rect.left - rect.left,image_rect.top - rect.top))
	#self.background = List()
    	#self.background.addobject(bg)	
    	#self.background.addobject(result)	
    	#self.background.addobject(result2)	
    	#self.background.addobject(result3)	

        self.background = pygame.image.load('bg_dungeonwaterhermit82.bmp').convert()

class Roomdungeonwatercherubs(Roomroomman):#FIXME Room
    ""

    def __init__(self, roomman):#,x,y):#, roomman):
        #Map
	Roomroomman.__init__(self, roomman)#,x,y)
#	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0,0,640,15)
	self.addbox(0,465,640,15)
	self.addbox(0,0,15,480)
	self.addbox(625,0,15,480)
	# ENEMIES
	#self.addentity(factory.make(Entity.ENTITY_TREE4, 10,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,200,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,100,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,200,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,250,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,0,300,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_CHERUBSTATUE1,100,100,130,130))

        key = Ringyellow(280,220,40,40,"3","1")
        self.addentity(key)
        key.readkeys(self.entities)

         # NORTH EXIT
	#self.addexit(100,110,50,100,3008,300,90,Worldmaproom3(-850,-50, self.roomman))
         # SOUTH EXIT
        self.addexit(0,460,640,20,3014,300,90,Dungeonwater4(200,-50, self.roomman))

        self.background = pygame.image.load('bg_dungeonwatercherubroom.bmp').convert()


class Worldmapinsidetemple1(Maproom):
    ""

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS with exit
	self.addbox(0,0,1400,100)
	self.addbox(1150,0,350,1000)
	self.addbox(0,0,100,1000)
	self.addbox(0,900,300,100)
	self.addbox(400,900,0,100)
	# PITS
	self.addbox(0,680,180,120)
	self.addbox(230,680,120,170)
	self.addbox(200,510,160,120)
	self.addbox(400,510,130,490)
	
	# PIT with stairs
	self.addbox(160,310,390,140)
	# PITS
	self.addbox(250,0,300,250)
	self.addbox(650,200,130,410)
	self.addbox(650,490,360,130)
	self.addbox(740,690,270,130)
	# MINI WALL
	self.addbox(1000,600,12,100)
	# ENEMIES
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUE,190,800,100,100))
        self.addentity(factory.make(Entity.ENTITY_UNICORNSTATUE,420,800,100,100))
	# FIXME
        #mage = factory.make(Entity.ENTITY_KOBOLDMAGE,450,800,130,130)
        #self.addenemy(mage)
        #mage.readkoboldmage(self.entities)
#        hobgoblinchief1 = factory.make(Entity.ENTITY_HOBGOBLINSWORDSMANCHIEF1,1000,350,30,30)
#        self.addenemy(hobgoblinchief1)
        
	#self.addentity(factory.make(Entity.ENTITY_TREE4, 10,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,200,0,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,50,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,100,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,10,200,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,100,250,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,0,300,130,130))
        #self.addentity(factory.make(Entity.ENTITY_TREE4,500,50,130,130))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,550,300,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,450,100,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,700,800,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,400,350,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,1000,400,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,900,900,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,800,500,70,50))

        #self.addentity(factory.make(Entity.ENTITY_KNIGHTDARK1,1000,700,70,50))
        self.addentity(factory.makewithboxes(Entity.ENTITY_BOUNCER1,1000,700,70,50, self.boxes))

        key = Key3(120,120,40,40,"3","1")
        self.addentity(key)
        key.readkeys(self.entities)

         # EAST EXIT RIGHT
        self.addexit(1150,100,400,120,3008,300,90,Dungeonwater4(110,-300, self.roomman))
	# WATERFORTRESS EXIT
        self.addexit(300,950,110,100,3011,300,90, Worldmaproomwaterfortress1(-1800,-1700, self.roomman))
	# STAIRS EXIT RIGHT
	self.addexit(810,390,80,80,3012,200,300, Worldmapinsidetemple4(0,0, self.roomman))

        self.background = pygame.image.load('bg_insidetemple11.bmp').convert()



class Worldmapinsidetemple2(Maproomchbg):
    ""

    def __init__(self,x,y, roomman):
        Maproomchbg.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS with exit
	self.addbox(0,0,1400,100)
	self.addbox(0,200,100,1000)
	self.addbox(0,890,500,100)
	self.addbox(750,890,650,100)
	self.addbox(1300,0,100,1000)
	# PIT
	self.addbox(500, 150, 650, 350)
	self.addbox(500, 500, 650, 240)
	#self.addbox(750, 740, 350, 240)
	self.addbox(700, 740, 300, 240)
	# LEFT PIT
	self.addbox(100, 160, 300, 340)

	# ITEMS 
        key = Key2(250,750,50,50,"3","2")
        self.addentity(key)
        key.readkeys(self.entities)

	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_BOUNCER1,250,750,70,50, self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_BOUNCER1,250,750,70,50, self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_BOUNCER1,250,750,70,50, self.boxes))
        # BOSS ENEMY GUARDING BLUE KEY (KEY2)
	self.addentity(factory.makewithboxes(Entity.ENTITY_OOZEBIG1,250,700,100,100, self.boxes))
	# FIXME
        #mage = factory.make(Entity.ENTITY_KOBOLDMAGE,450,800,130,130)
        #self.addenemy(mage)
        #mage.readkoboldmage(self.entities)
        
        #self.addentity(factory.make(Entity.ENTITY_TREE4,450,100,130,130))


         # SOUTH EXIT TO WATERFALL
        self.addexit(600,900,100,100,3014,250,110,Worldmapinsidetemple5(0,0, self.roomman))
	# BIG STAIRS EXIT
        self.addexit(200,880,200,100,3012,550,200, Worldmapinsidetemple6(self.roomman))
	# UPPER LEFT EXIT
        self.addexit(0,100,100,100,3023,300,100, Dungeonwaterlowermountains1(-2600,0, self.roomman))
        # PLATFORMS
	self.addentity(factory.make(Entity.ENTITY_PLATFORMMAPROOM1,550,760,80,130))

        bg = pygame.image.load('bg_insidetemple21.bmp').convert()
	shadow = pygame.image.load('bg_candle1.bmp').convert()
	shadow2 = pygame.image.load('bg_candle2.bmp').convert()
	shadow3 = pygame.image.load('bg_candle3.bmp').convert()
        bg.set_alpha(200)
        image = bg
	#buf = bg.get_buffer()#pygame.surfarray.array2d(bg)
	shadow_offset = (1400,1000)
    	image_rect = image.get_rect()
    	shadow_rect2 = shadow2.get_rect()
    	shadow_rect3 = shadow3.get_rect()
    	shadow_rect = shadow.get_rect()
    	shadow_rect.center = image_rect.center
    	shadow_rect.move_ip(shadow_offset)
    	rect = image_rect.union(shadow_rect)
    	result = pygame.Surface(rect.size, pygame.SRCALPHA, 32)
    	result2 = pygame.Surface(rect.size, pygame.SRCALPHA, 32)
    	result3 = pygame.Surface(rect.size, pygame.SRCALPHA, 32)
    	result3.blit(shadow3, (0,0))#(shadow_rect.left - rect.left,shadow_rect.top - rect.top))
    	result3.blit(image, (0,0))#(image_rect.left - rect.left,image_rect.top - rect.top))
    	result2.blit(shadow2, (0,0))#(shadow_rect.left - rect.left,shadow_rect.top - rect.top))
    	result2.blit(image, (0,0))#(image_rect.left - rect.left,image_rect.top - rect.top))
    	result.blit(shadow, (0,0))#(shadow_rect.left - rect.left,shadow_rect.top - rect.top))
    	result.blit(image, (0,0))#(image_rect.left - rect.left,image_rect.top - rect.top))
	self.background = List()
    	#self.background.addobject(bg)	
    	self.background.addobject(result)	
    	self.background.addobject(result2)	
    	self.background.addobject(result3)	


# RATS
class Worldmapinsidetemple4(Maproomleftright):
    ""

    def __init__(self,x,y, roomman):
        Maproomleftright.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS with exit
	self.addbox(0, 0, 1000, 50)
	self.addbox(0, 0, 50, 480)
	self.addbox(0, 430, 1000, 50)
	self.addbox(950, 0, 50, 480)

	# WATER PITS
	self.addbox(360, 170, 80, 150)
	self.addbox(560, 170, 80, 150)
	
	# ENEMIES
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,550,300,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,450,100,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,700,200,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,400,350,70,50))
        self.addentity(factory.make(Entity.ENTITY_BATCRAZY,1000,400,70,50))
         # SOUTH STAIRS EXIT
        self.addexit(100,350,100,100,3008,300,90,Worldmapinsidetemple1(-730,-400, self.roomman))
        # DOOR RIGHT 
	self.addexit(800,0,100,100,3008,220,300,Worldmapinsidetemple5(0,-600, self.roomman))
	# NOTE bg 4 is bg 3 here !
        self.background = pygame.image.load('bg_insidetemple3.bmp').convert()

class Worldmapinsidetemple5(Maproomupdown):
    "Waterfall/source room"

    def __init__(self,x,y, roomman):
        Maproomupdown.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS 
	self.addbox(0, 0, 50, 1000)
	self.addbox(0, 0, 480, 30)
	self.addbox(380, 0, 50, 1000)
	self.addbox(0, 920, 480, 50)

	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_BOUNCER1,100,600,70,50, self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_BOUNCER1,100,500,70,50, self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_BOUNCER1,100,400,70,50, self.boxes))

        # SOUTH EXIT
	# TO DUNGEON DOOR ROOM 
        self.addexit(200,950,100,100,3018,220,300,Worldmapinsidetemple4(-630,0, self.roomman))
	# NORTH EXIT WATERFALL
        self.addexit(150,0,100,100,301,220,300,Worldmapinsidetemple2(-425,-500, self.roomman))
	# NOTE : bg 5 is bg 4
        self.background = pygame.image.load('bg_insidetemple4.bmp').convert()

	
class Worldmapinsidetemple6(Roomroomman):
    "Left big stairs lead to this room. from the magical candle chamber with the big blue ooze. This room also has a waterfall"

    def __init__(self,roomman):
        Roomroomman.__init__(self, roomman)
	#self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS 
	self.addbox(0, 0, 50, 480)
	self.addbox(0, 0, 640, 50)
	self.addbox(0, 430, 640, 50)
	self.addbox(590, 0, 50, 480)

	# ENEMIES
        #self.addenemycig 100(factory.makewithboxes(Entity.ENTITY_BOUNCER1,100,400,70,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,250,100,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,350,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,150,250,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,250,110,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,90,70,70, self.boxes))

        # EAST EXIT
	# TO DUNGEON DOOR ROOM 
        self.addexit(585,180,50,140,3019,220,300,Worldmapinsidetemple2(0,-550, self.roomman))
	# SOUTH EXIT OF UPPER  WATERFALL
        self.addexit(190,420,110,60,301,220,100,Worldmapinsidetemple7(self.roomman))
	# NOTE : bg 5 is bg 4
        self.background = pygame.image.load('bg_insidetemple61.bmp').convert()

	
	
class Worldmapinsidetemple7(Roomroomman):
    "This room is down of the upper source waterfall"

    def __init__(self,roomman):
        Roomroomman.__init__(self, roomman)
	#self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS 
	self.addbox(0, 0, 50, 480)
	#self.addbox(0, 0, 640, 50)
	self.addbox(0, 430, 190, 50)
	self.addbox(300, 430, 340, 50)
	self.addbox(590, 0, 50, 480)

	# ENEMIES
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_BOUNCER1,100,400,70,50, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,250,100,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,350,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,150,250,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,250,110,70,70, self.boxes))
        self.addenemy(factory.makewithboxes(Entity.ENTITY_WATERDEVIL,450,90,70,70, self.boxes))

	# NORTH EXIT WATERFALL
        self.addexit(100,0,440,60,301,220,410,Worldmapinsidetemple6(self.roomman))
	# SOUTH EXIT 
        self.addexit(190,450,110,50,301,220,100,Worldmapinsidetemple8(self.roomman))
	# NOTE : bg 5 is bg 4
        self.background = pygame.image.load('bg_insidetemple7.bmp').convert()

	
	
	
class Worldmapinsidetemple8(Roomroomman):
    "This room is down twice of the upper source waterfall"

    def __init__(self,roomman):
        Roomroomman.__init__(self, roomman)
	#self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS 
	self.addbox(0, 0, 50, 480)
	self.addbox(0, 430, 640, 50)
	self.addbox(0, 430, 640, 50)
	self.addbox(590, 0, 50, 480)

	# ITEMS 
        key = Sword1blue(280,220,60,60,"3","1")
        self.addentity(key)
        key.readkeys(self.entities)
	# ENEMIES
        self.addenemy(factory.make(Entity.ENTITY_WATERDEVILFEMALE,450,150,70,120))
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_BOUNCER1,100,400,70,50, self.boxes))

	# NORTH EXIT TO WATERFALL
        self.addexit(100,0,440,60,301,220,410,Worldmapinsidetemple7(self.roomman))
	# NOTE : bg 5 is bg 4
        self.background = pygame.image.load('bg_insidetemple8.bmp').convert()

	
	
	
	
class Roombirdforest(Maproom):
    "This room has a forest in it with a sparrow"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self, x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS 
	self.addbox(0, 0, 50, 1300)
	self.addbox(0, 1250, 1300, 50)
	self.addbox(0, 0, 1300, 50)
	self.addbox(1250, 0, 50, 1300)

	# ITEMS 
        # ENTITIES
        self.addentity(factory.make(Entity.ENTITY_SPARROW,800,700,80,80))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 100,0,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 300,100,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 500,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 700,450,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 120,760,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 440,40,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 560,750,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 780,780,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 890,600,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 900,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 400,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 400,300,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 800,1000,130,130))
	self.addentity(factory.make(Entity.ENTITY_TREE3, 500,1100,130,130))
	
	self.addentity(factory.make(Entity.ENTITY_ENSORCELLEDTREE, 180,220,150,150))
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_TROLLBLACK,400,800,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_TROLLBLACK,100,600,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_TROLLBLACK,800,300,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_TROLLBLACK,900,400,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_TROLLBLACK,800,200,50,50,self.boxes))
        #self.addenemy(factory.makewithboxes(Entity.ENTITY_BOUNCER1,100,400,70,50, self.boxes))
        #self.addentity(factory.make(Entity.ENTITY_NUTTER1,300,220,80,80))

	# EXITS  FOO
        self.addexit(1250,0,50,100,3011,120,200,Roomforest1(0,-200, self.roomman))
	# EXIT UNDER ENSORCELLED TREE
        self.addexit(220,280,70,70,3030,260,300,Dungeonundertree1(0,0,self.roomman))
        self.background = pygame.image.load('bg_insidetemple9.bmp').convert()

	
	
class NutGrove1(Maproom):
    "Nut Grove"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self, x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
        self.addfactory(factory)

	# OUTER WALLS 
	# left 
	self.addbox(0, 0, 50, 480)
	# under 
	self.addbox(0, 430, 260, 50)
	self.addbox(320, 430, 320, 50)
	# above
	self.addbox(0, 0, 260, 50)
	self.addbox(320, 0, 320, 50)
	# right
	self.addbox(590, 0, 50, 200)
	self.addbox(590, 280, 50, 200)

	# ITEMS 
        # ENTITIES
        self.addentity(factory.make(Entity.ENTITY_TREE2,0,20,180,130))
        ###self.addentity(factory.make(Entity.ENTITY_TREE2,120,100,130,130))
        ###self.addentity(factory.make(Entity.ENTITY_TREE2,40,200,330,130))
	# ENEMIES
        self.addentity(factory.make(Entity.ENTITY_NUTTER1,400,320,80,80))
        self.addentity(factory.make(Entity.ENTITY_NUTTER2,500,320,80,80))
	
	# EXITS
	# SOUTH EXIT 
        ### JUMP self.addexit(260,420,80,80,3011,100,300,Roombirdforest(0,0, self.roomman))
	# NORTH EXIT 
        self.addexit(260,0,80,80,3030,330,360,NutGrove2(0,0, self.roomman))
        # EAST EXIT 
	self.addexit(600,200,40,80,3030,90,210,Room4world(self.roomman))

        self.background = pygame.image.load('bg_dungeonundertree1.bmp').convert()

	
class NutGrove2(Room):
    "This room is under the tree 2 - north of nut grove"

    def __init__(self,x,y, roomman):
        ### Maproom.__init__(self, x,y)
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS 
	self.addbox(0, 0, 50, 640)
	self.addbox(590, 0, 50, 480)
	self.addbox(0, 430, 230, 50)
	self.addbox(280, 430, 280, 50)

	# ITEMS 
        # ENTITIES
	# ENEMIES
	self.addentity(factory.make(Entity.ENTITY_TREE6, 80,200,150,150))
	self.addentity(factory.make(Entity.ENTITY_TREE6, 380,200,150,150))
        ### self.addentity(factory.make(Entity.ENTITY_BLIMP,0,-20,150,150))

	# EXITS 
        self.addexit(270,180,50,70,3031,110,280,NutGrove3(0,0, self.roomman))
        self.addexit(260,400,80,80,3030,300,90,NutGrove1(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertree2.bmp').convert()












class NutGrove3(Room):
    "Arrow nutter village room"

    def __init__(self,x,y, roomman):
        ### Maproom.__init__(self, x,y)
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 100)
	# under
	self.addbox(0, 400, 70, 80) 
	self.addbox(200, 350, 440, 130)
	# TRI BOXES
	self.addtribox1(0, -200, 100, 0) 
	# ITEMS 
        # ENTITIES
	# ENEMIES

	# EXITS 
        self.addexit(70,380,130,100,3036,270,310,NutGrove2(0,0, self.roomman))
        self.addexit(600,0,40,480,3037,70,210,NutGrove4(0,0, self.roomman))
        self.addexit(0,300,70,180,3038,560,330,Cavernsofdespair1(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertree6.1.bmp').convert()




class NutGrove4(Maproom):
    "This room is the nutter village"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self, x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 1300, 100)
	# under 
	self.addbox(0, 900, 1300, 100)
	# left 
	self.addbox(0, 375, 100, 900)
	# right 
	self.addbox(1150, 0, 100, 1000)
	self.addbox(0, 600, 600, 80)
	self.addbox(690, 600, 1000, 80)
	# houses
	self.addbox(50, 0, 150, 150)
	self.addbox(340, 240, 150, 150)
	self.addbox(700, 0, 150, 150)
	self.addbox(975, 240, 150, 150)
	# wizard house
	self.addbox(1100, 650, 150, 150)

	# ITEMS 
        # ENTITIES
        self.addentity(factory.make(Entity.ENTITY_NUTTER3,600,220,80,80))
        self.addentity(factory.make(Entity.ENTITY_NUTTER4,250,320,80,80))
	# ENEMIES
        	### self.addentity(factory.makewithscreen(Entity.ENTITY_NUTTERNOOTIE,1000,730,80,80, self.roomman.screen))

	# EXITS
	# HOUSE 1 EXIT 
        self.addexit(100,100,80,80,3036,300,300,NutGrove4house1(0,0, self.roomman))
	# HOUSE 2 EXIT 
        self.addexit(750,100,80,80,3036,300,300,NutGrove4house2(0,0, self.roomman))
	# HOUSE 3 EXIT 
        self.addexit(400,350,80,80,3036,300,300,NutGrove4house3(0,0, self.roomman))
	# HOUSE 4 EXIT 
        self.addexit(1075,400,80,80,3036,300,300,NutGrove4house4(0,0, self.roomman))
	# HOUSE 5 NOOTIE EXIT 
        self.addexit(1100,750,80,80,3036,300,300,NutGrove4house5nootie(0,0, self.roomman))
        self.addexit(0,0,40,375,3036,580,210,NutGrove3(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertree7.1.bmp').convert()



class NutGrove4house1(Room):
    "This room is the nutter village - inside house 1"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 120)
	# under 
	self.addbox(0, 340, 300, 100)
	self.addbox(320,340, 320, 100)
	# left 
	self.addbox(0, 0, 200, 480)
	# right 
	self.addbox(460, 0, 100, 480)

	# ITEMS 
        # ENTITIES
	# ENEMIES

	# EXITS 
        self.addexit(300,320,80,80,3036,100,185,NutGrove4(0,0, self.roomman))
        self.background = pygame.image.load('bg_nutgrovehouse1.bmp').convert()


class NutGrove4house2(Room):
    "This room is the nutter village - inside house 1"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 120)
	# under 
	self.addbox(0, 340, 300, 100)
	self.addbox(320,340, 320, 100)
	# left 
	self.addbox(0, 0, 200, 480)
	# right 
	self.addbox(460, 0, 100, 480)

	# ITEMS 
        # ENTITIES
	# ENEMIES

	# EXITS 
        self.addexit(300,320,80,80,3036,200,185,NutGrove4(-600,0, self.roomman))
        self.background = pygame.image.load('bg_nutgrovehouse1.bmp').convert()

class NutGrove4house3(Room):
    "This room is the nutter village - inside house 1"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 120)
	# under 
	self.addbox(0, 340, 300, 100)
	self.addbox(320,340, 320, 100)
	# left 
	self.addbox(0, 0, 200, 480)
	# right 
	self.addbox(460, 0, 100, 480)

	# ITEMS 
        # ENTITIES
	# ENEMIES

	# EXITS 
        self.addexit(300,320,80,80,3036,390,250,NutGrove4(-20,-200, self.roomman))
        self.background = pygame.image.load('bg_nutgrovehouse1.bmp').convert()


class NutGrove4house4(Room):
    "This room is the nutter village - inside house 1"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 120)
	# under 
	self.addbox(0, 340, 300, 100)
	self.addbox(320,340, 320, 100)
	# left 
	self.addbox(0, 0, 200, 480)
	# right 
	self.addbox(460, 0, 100, 480)

	# ITEMS 
        # ENTITIES
	# ENEMIES
	# EXITS 
        self.addexit(300,320,80,80,3036,350,250,NutGrove4(-600,-100, self.roomman))
        self.background = pygame.image.load('bg_nutgrovehouse1.bmp').convert()

class NutGrove4house5nootie(Room):
    "This room is the nutter village - inside house 5 of Nootie"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 120)
	# under 
	self.addbox(0, 340, 300, 100)
	self.addbox(320,340, 320, 100)
	# left 
	self.addbox(0, 0, 200, 480)
	# right 
	self.addbox(460, 0, 100, 480)

	# ITEMS 
        # ENTITIES
	# ENEMIES
        	### self.addenemy(factory.make(Entity.ENTITY_DJINNOFNOOTIE,150,170,120,120))

	# EXITS 
        self.addexit(300,320,80,80,3036,350,250,NutGrove4(-600,-500, self.roomman))
        self.background = pygame.image.load('bg_nutgrovehouse1.bmp').convert()
###########################################################
###########################################################
# DUNGEON 5 
###########################################################
###########################################################


class Cavernsofdespair1(Room):
    "This room is under the tree 8 - left of village arrow room"
    #"with caverns of despair sign"

    def __init__(self,x,y, roomman):
        ### Maproom.__init__(self, x,y)
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 100)
	# under
	self.addbox(0, 350, 70, 130) 
	self.addbox(200, 350, 440, 130)
	# TRI BOXES 1
	self.addtribox1(0, -200, 100, 0) 
	# TRI BOXES 2 
	self.addtribox2(640, -200, 440, 0) 
	# ITEMS 
        # ENTITIES
        key = Chestmanapotion(300,100,50,50,"3","2")
        if key.readkeys(self.entities):
		self.addentity(key)
	food = Food(200,200,40,40)
        self.entities.add(food)
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN,220,220,80,80,self.boxes))

	# EXITS
	# EAST EXIT 
        self.addexit(600,300,80,180,3036,80,305,NutGrove3(0,0, self.roomman))
	# WEST EXIT 
        self.addexit(50,315,80,100,3036,465,270,Cavernsofdespair2(0,0, self.roomman))
        self.background = pygame.image.load('bg_cavernsofdespair1.bmp').convert()


class Cavernsofdespair2(Room):
    ""

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS
	self.addbox(-50, 0, 50, 480)
	
	# WALLS
	# above 
	self.addbox(0, 0, 640, 100)
	# under
	self.addbox(0, 400, 640, 100)
	# right
	self.addbox(540, 0, 100, 480)
	# middle
	self.addbox(0, 180, 440, 100)
	self.addbox(370, 180, 80, 300)
	# TRI BOXES 1
	# TRI BOXES 2 
	# ITEMS 
        # ENTITIES
        ### self.addentity(factory.make(Entity.ENTITY_TOADSTOOL,100,210,70,70))
        ### self.addentity(factory.make(Entity.ENTITY_ENTSTONE,0,110,70,70))
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN2,120,110,80,80,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN2,120,310,80,80,self.boxes))
	# ENEMIES

	# EXITS
	# SOUTH-ENTRANCE 
        self.addexit(400,390,80,180,3036,155,315,Cavernsofdespair1(0,0, self.roomman))
	# WEST UP EXIT
        self.addexit(0,0,80,180,3036,550,325,Cavernsofdespair3(0,0, self.roomman))
        self.background = pygame.image.load('bg_cavernsofdespair2.bmp').convert()


class Cavernsofdespair3(Room):
    ""

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0, 0, 350, 50)
	self.addbox(640, 0, 100, 480)
	
	# WALLS
	# left
	self.addbox(0, 0, 30, 480)
	# under
	self.addbox(0, 350, 640, 80)
	# middle
	self.addbox(350, 0, 100, 150)
	self.addbox(350, 150, 290, 80)
	# TRI BOXES 1
	# TRI BOXES 2 
	# ITEMS 
        chest = Chest1(445,100,50,50,"3","3")
        if chest.readkeys(self.entities):
		self.addentity(chest)
        # ENTITIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN2,120,110,80,80,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN,120,110,80,80,self.boxes))
	# ENEMIES

	# EXITS
	# EAST LOWER EXIT
        self.addexit(560,250,80,180,3036,105,115,Cavernsofdespair2(0,0, self.roomman))
	# EAST UPPER EXIT
        self.addexit(560,50,80,130,3036,105,315,Cavernsofdespair6(self.roomman))
	# NORTH LEFT EXIT JUMP
        self.addexit(100,0,200,80,3034,200,305,Cavernsofdespair4(0,-450, self.roomman))
	# NORTH RIGHT EXIT JUMP
        self.addexit(420,0,120,50,3034,200,305,Cavernsofdespair4(-330,-450, self.roomman))
        self.background = pygame.image.load('bg_cavernsofdespair3.bmp').convert()


class Cavernsofdespair4(Maproom):
    "above big (map) room split in two "

    def __init__(self,x,y, roomman):
        Maproom.__init__(self,x,y)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0, 0, 900, 50)
	self.addbox(0, 0, 100, 900)
	self.addbox(800, 0, 100, 900)
	self.addbox(0, 800, 900, 100)
	
	# WALLS
	self.addbox(310, 0, 105, 900)
	# TRI BOXES 1
	# TRI BOXES 2 
	# ITEMS 
        # ENTITIES
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN2,120,110,80,80,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN,120,210,80,80,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN2,220,110,80,80,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN,220,210,80,80,self.boxes))

        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,520,210,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,620,210,50,50,self.boxes))

        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,520,310,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,620,310,50,50,self.boxes))

        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,520,410,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,620,410,50,50,self.boxes))

        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,520,510,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_GOBLINGUARDIAN,620,510,50,50,self.boxes))
	# EXITS
	# SOUTH LEFTDOWN EXIT
        self.addexit(100,850,100,80,3036,100,85,Cavernsofdespair3(0,0, self.roomman))
	# SOUTH RIGHTDOWN EXIT
        self.addexit(600,770,100,80,3036,500,90,Cavernsofdespair3(0,0, self.roomman))
	# NORTH LEFT EXIT to tunnel
        self.addexit(200,80,100,60,3036,100,235,Cavernsofdespair5(self.roomman))
	# NORTH RIGHT EXIT to tunnel
        self.addexit(650,0,100,80,3036,470,235,Cavernsofdespair5(self.roomman))
        self.background = pygame.image.load('bg_cavernsofdespair4.bmp').convert()

class Cavernsofdespair5(Room):
    "above (map)rooms 1 - tunnel"

    def __init__(self,roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0, -50, 480, 50)
	self.addbox(0, 0, 75, 480)
	self.addbox(0, 280, 640, 170)
	self.addbox(560, 0, 80, 480)
	
	# WALLS
	self.addbox(0, 0, 220, 200)
	self.addbox(380, 0, 220, 200)
	# TRI BOXES 1
	# TRI BOXES 2 
	# ITEMS 
        # ENTITIES
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN2,120,210,80,80,self.boxes))

	# EXITS
	# SOUTH LEFTDOWN EXIT
        self.addexit(100,280,100,80,3036,100,85,Cavernsofdespair4(0,0, self.roomman))
	# SOUTH RIGHTDOWN EXIT
        self.addexit(480,280,100,105,3036,320,150,Cavernsofdespair4(-320,0, self.roomman))
        self.background = pygame.image.load('bg_cavernsofdespair5.bmp').convert()



class Cavernsofdespair6(Room):
    "right under of (map)room 1"

    def __init__(self,roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(0, 0, 640, 50)
	self.addbox(0, 0, 75, 480)
	self.addbox(0, 400, 640, 80)
	self.addbox(560, 0, 80, 480)
	
	# WALLS-TREES
	self.addbox(0, 0, 640, 160)
	# TRI BOXES 1
	# TRI BOXES 2 
	# ITEMS 
        # ENTITIES
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_ORCGUARDIAN2,120,210,80,80,self.boxes))

	# EXITS
	# WEST EXIT
        self.addexit(0,280,80,100,3036,435,85,Cavernsofdespair3(0,0,self.roomman))
	# EAST EXIT
        self.addexit(560,160,80,320,3036,100,385,Cavernsofdespair7(self.roomman))
        self.background = pygame.image.load('bg_cavernsofdespair6.bmp').convert()




class Cavernsofdespair7(Room):
    "At Nootie's Mansion"
        ### self.addexit(0,80,80,120,5003,589,355,Cavernsofdespair3(0,0, self.roomman))

    def __init__(self,roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(-50, 0, 50, 480)
	
	# WALLS
	# above 
	self.addbox(0, 0, 640, 310)
	# TRI BOXES 1
	# TRI BOXES 2 
	# ITEMS 
        # ENTITIES
	# ENEMIES

	# EXITS
	#  WEST
        ### self.addexit(0,80,80,120,5003,589,355,Cavernsofdespair3(0,0, self.roomman))
        self.addexit(0,300,80,180,3036,105,315,Cavernsofdespair6(self.roomman))
	# TREEHOUSE EXIT 
        self.addexit(380,280,80,60,3036,340,270,CavernsofdespairNootiehouse1(0,0, self.roomman))
        self.background = pygame.image.load('bg_cavernsofdespairtreehouse1.bmp').convert()


class CavernsofdespairNootiehouse1(Room):
    "Inside of Nootie's Mansion"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 640, 120)
	# under 
	self.addbox(0, 340, 300, 100)
	self.addbox(320,340, 320, 100)
	# left 
	self.addbox(0, 0, 200, 480)
	# right 
	self.addbox(460, 0, 100, 480)

	# ITEMS 
        spellbook = Spellbooknootie(300,90,80,80,"3","1")
        self.addenemy(spellbook)
        spellbook.readspellbook(self.entities)
        # ENTITIES
	# ENEMIES
        self.addenemy(factory.make(Entity.ENTITY_DJINNOFNOOTIE,150,170,120,120))
        self.addenemy(factory.makewithscreen(Entity.ENTITY_NUTTERNOOTIE,350,170,120,120,self.roomman.screen))

	# EXITS 
        self.addexit(300,320,80,80,3036,550,385,Cavernsofdespair7(self.roomman))
        ###self.addexit(340,280,80,80,3036,350,350,Cavernsofdespair3(0,0, self.roomman))
        self.background = pygame.image.load('bg_nutgrovehouse1.bmp').convert()





###########################################################
###########################################################
# DUNGEON 4
###########################################################
###########################################################
class Dungeonundertree1(Room):
    "This room is under the tree 1 - west west of sea"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS 
	self.addbox(0, 0, 280, 100)
	self.addbox(320, 0, 340, 100)
	self.addbox(0, 0, 150, 480)
	self.addbox(500, 0, 140, 480)
	self.addbox(0, 350, 640, 130)

	# ITEMS 
        # ENTITIES
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_TROLLBLACK,200,200,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_TROLLBLACK,200,200,50,50,self.boxes))

	# EXITS JUMP 
        self.addexit(280,330,80,80,3011,100,300,Roombirdforest(0,0, self.roomman))
        self.addexit(290,0,80,80,3031,305,400,Dungeonundertree2(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertree3.bmp').convert()

class Dungeonundertree2(Room):
    "This room is under the tree 2"

    def __init__(self,x,y, roomman):
        ### Maproom.__init__(self, x,y)
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS 
	self.addbox(0, 0, 150, 480)
	self.addbox(500, 0, 140, 480)
	# above
	self.addbox(0, 0, 280, 100)
	self.addbox(320, 0, 340, 100)
	# under
	self.addbox(0, 380, 260, 100)
	self.addbox(350, 380, 290, 100)

	# ITEMS 
        # ENTITIES
        self.addentity(factory.make(Entity.ENTITY_GHOSTSTORY,200,160,80,120))
	# ENEMIES

	# EXITS
	# SOUTH EXIT
        self.addexit(290,420,80,80,3030,305,100,Dungeonundertree1(0,0, self.roomman))
	# NORTH EXIT
        self.addexit(290,0,80,80,3031,305,400,Dungeonundertree3(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertree4.bmp').convert()


class Dungeonundertree3(Room):
    "This room is under the tree 3 in the north - 1st room with grey knights"

    def __init__(self,x,y, roomman):
        ### Maproom.__init__(self, x,y)
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 100, 100)
	self.addbox(200, 0, 440, 100)
	self.addbox(0, 0, 640, 20)
	# left
	self.addbox(0, 0, 100, 400)
	# right 
	self.addbox(560, 0, 80, 400)
	# under
	self.addbox(0, 300, 290, 180)
	self.addbox(340, 300, 300, 180)
	self.addbox(0, 480, 640, 100)

	# ITEMS 
        # ENTITIES
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_KNIGHTGREY,100,200,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_KNIGHTGREY,200,200,50,50,self.boxes))
        self.addentity(factory.makewithboxes(Entity.ENTITY_KNIGHTGREY,300,200,50,50,self.boxes))

	# EXITS
	# SOUTH EXIT
        self.addexit(290,420,80,80,3030,305,100,Dungeonundertree2(0,0, self.roomman))
	# NORTH EXIT
        self.addexit(100,0,100,120,3036,300,300,Dungeonundertree4(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertree5.bmp').convert()



class Dungeonundertree4(Room):
    "This room is under the tree 3 in the north - north of knights"

    def __init__(self,x,y, roomman):
        ### Maproom.__init__(self, x,y)
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS
	# above 
	self.addbox(0, 0, 280, 270)
	self.addbox(360, 0, 180, 270)
	
	self.addbox(0, 0, 200, 480)
	self.addbox(0, 350, 640, 130)
	self.addbox(450, 0, 190, 480)

	# ITEMS 
        # ENTITIES
        self.addentity(Wallwalksmallcave(270,150,100,100,"3","1"))
	# ENEMIES

	# EXITS
	# SOUTH EXIT
        self.addexit(200,340,100,100,3030,155,150,Dungeonundertree3(0,0, self.roomman))
	# NORTH EXIT
        self.addexit(280,120,80,100,3036,300,390,DungeonundertreeCastle1(-100,-200, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertree9.bmp').convert()


class DungeonundertreeCastle1(Maproom):
    "This room is under the tree 3 in the north - north of knights"

    def __init__(self,x,y, roomman):
        Maproom.__init__(self, x,y)
        ### Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()
	###FIXME factory.add(self)

	# OUTER WALLS
	self.addbox(0, 0, 800, 30)
	self.addbox(0, 0, 30, 800)
	self.addbox(0, 800, 800, 30)
	self.addbox(800, 0, 30, 800)

	# STONE PLATEAUS
	self.addbox(275, 50, 100, 225)
	self.addbox(50, 250, 100, 225)
	self.addbox(350, 325, 100, 225)
	self.addbox(175, 575, 100, 225)
	self.addbox(500, 100, 100, 225)
	self.addbox(600, 485, 100, 225)

	# PURPLE WOODS
	self.addbox(370, 0, 100, 100)
	# STATUES 
	self.addbox(370, 75, 50, 50)
	self.addbox(475, 75, 50, 50)
	
	# ITEMS 
        # ENTITIES
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_ASSASSIN,200,200,50,50,self.boxes))

	# EXITS
	# SOUTH EXIT
        self.addexit(0,650,800,100,3030,300,300,Dungeonundertree4(0,0, self.roomman))
	# NORTH TOWARDS QUEEN ROOM EXIT
        self.addexit(425,75,100,50,3036,330,238,DungeonundertreeCastle2(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertreecastle1.bmp').convert()



class DungeonundertreeCastle2(Room):
    "Assassin queen room"

    def __init__(self,x,y, roomman):
        Room.__init__(self)
	self.roomman = roomman

    def loadroom(self):
        self.initroom()
        self.loadroom1()
        return self

    def loadroom1(self):

	factory = Entityfactory()

	# OUTER WALLS
	self.addbox(100, 100, 640, 30)
	self.addbox(100, 0, 30, 480)
	self.addbox(0, 280, 640, 30)
	self.addbox(480, 0, 30, 480)

	# STATUES 
	### self.addbox(475, 75, 70, 70)
	
	# ITEMS 
        # ENTITIES
	# ENEMIES
        self.addentity(factory.makewithboxes(Entity.ENTITY_ASSASSINQUEEN,200,200,50,75,self.boxes))

	# EXITS
	# SOUTH EXIT
        self.addexit(0,250,640,100,3030,450,170,DungeonundertreeCastle1(0,0, self.roomman))
        self.background = pygame.image.load('bg_dungeonundertreecastle2.bmp').convert()

\end{verbatim}
\end{mylisting}

\section{\large Conclusion}


\bibliographystyle{plain}
\bibliography{refs} % refs.bib

\end{document}


